Flex FTP Make Directory

I’m messing around with Flex FTP at the moment and found that there is no way yet to create a directory on the FTP server. I had a quick look through the code on how the other FTP actions were implemented. Being surprised with the nice setup of the code I had quite easily added the “make directory” action and got it working properly. You can download my MakeDirInv class here: http://ansuz.nl/toys/randomcode/MakeDirInv.as
All you need to do after that is patch the FTPClient class by adding the following method.

ActionScript

  1. /**
  2. * Creates a directory on the remote host.
  3. *
  4. * @param newDirName The name of the new directory to create.
  5. * @param parentDir (Optional) The directory to create the new directory in.
  6. */
  7. public function makeDir(newDirName:String, parentDir:String = "/"):void {
  8. trace("FTPClient.makeDir(newDirName, parentDir)");
  9. invoke(new MakeDirInv(this, newDirName, parentDir));
  10. }

Once you’ve done that, you’re ready to create directories on the FTP server you’re connected to, see the example below.

ActionScript

  1. ftpClient.addEventListener(FTPEvent.CREATE_DIR, dirCreatedHandler);
  2. ftpClient.makeDir("myNewDir", "/someSubDir/");

PS: This isn’t fully tested yet, so do let me know if you find some bugs.

Links

De MonsterDebugger

I’m always looking for a nice debugger to use on the fly, the “De MonsterDebugger” looks really nice.

De MonsterDebugger is an open source debugger for Adobe Flash, Flex and AIR. De MonsterDebugger is made in Flex and AIR by design studio De Monsters.

One of the nicest features in my opinion is the live editing of properties, very handy when fiddling to position elements correctly.

Links:

Flex IRC Client

Just came across this when browsing around a bit. This Flex IRC client is a port of the Java-based PircBot.

Flex IRC Client aims to be a Flex / Flash based IRC Client. Currently most browser-based chat solutions are either proprietary or applets. Flex IRC Client wants to bring the power of IRC to the majority of the Internet-users without requiring a download or an install.

I know this client is still under development, but it could really do with a window showing some progress when connecting to a server. Also, a proxy of sorts would be nice since I get a lot of Security Errors when trying to connect to a server: “SecurityErrorEvent type=”securityError” bubbles=false cancelable=false eventPhase=2 text=”Error #2048: Security sandbox violation: http://ansuz.nl/toys/irc/FlexIRCClient.swf cannot load data from irc.efnet.nl:6667.””, probably due to no cross-domain policies being set on the IRC servers. Connecting works when running this locally 😉

Links

AS Frameworks

Recently I’ve been looking into different frameworks, just to get some experience with other interesting frameworks out there. I’ve compiled a list of some of the frameworks I’ve found. I’m sure I’ve missed a couple of other good ones, if you know of one, please let me know. 🙂

Gaia
A framework package as a Flash component. Handy for designers, but it kinda made me shrug… Though reading through the docs a couple of interesting features showed through, like the generation of the navigation through the context menu.
Link: http://www.gaiaflashframework.com/index.php

Cairngorm
Used this framework / micro architecture a lot already. Nice Event-Command pairs as well as delegates for calling all (web)services.
Link: http://opensource.adobe.com/wiki/display/cairngorm/Cairngorm

PureMVC
I’ve been working with a PureMVC project lately and looked at it before, quite similar in some ways to Cairngorm, just different names. 😉
A nice resource for pureMVC: http://puremvc.tv/
Link: http://puremvc.org/

Swiz

Swiz is a framework for Adobe Flex that aims to bring complete simplicity to RIA development. Swiz provides Inversion of Control, event handing, and simple life cycle for asynchronous remote methods.

Link: http://code.google.com/p/swizframework/

Dawn

Dawn is a lightweight framework for ActionScript inspired by Google Guice. In addition to Dependency Injection, it provides type safe notifications and helps you to build apps which are loosely coupled, easily unit tested, and less error-prone.

Link: http://wiki.github.com/sammyt/dawn

Mate

Mate is a tag-based, event-driven Flex framework.

Mate framework has been created to make it easy to handle the events your Flex application creates. Mate allows you to define who is handling those events, whether data needs to be retrieved from the server, or other events need to be triggered.

In addition, Mate provides a mechanism for dependency injection to make it easy for the different parts of your application to get the data and objects they need.

Link: http://mate.asfusion.com/

I think I’m going to give Dawn a try soon enough, of all the above it looks the most interesting to me.

AS3 Version Injection + Flex PMD + TDSI = Rock ‘n Roll! \m/

AS3 Version Injection

Ever been annoyed by Project Managers telling you that a bug you fixed is still in the latest release you did and after some investigation find out that they forgot to clear their cache? Well, fear not! An AS3 Version Injection script is here! 😛
I’ve created a simple AS3 class called Version that will add a time stamp to the context menu. All you need to do is instantiate the Version class once and pass it a reference to you Document Class. On top of the AS I’ve written a little Ant script that will take a template of the Version class, insert the current date and time and write out the Version class. This way you can just make it part of your Ant build and don’t need to worry about manually updating the version number. Also, now you’ll have a way of quickly identifying what version somebody is looking at. 🙂

Flex PMD

This is great for auditing your own code as well as other people’s code. I’ve written a small Ant task that can be ran as part of a build that will run your project through Flex PMD and create a PMD file for you. The PMD file will have a time stamp suffix so you don’t overwrite your old file and you can compare issues. To use this Ant script make sure you’ve downloaded PMD for Ant.

TDSI

Another piece of very useful technology. Up to 20% performance increase just by passing your SWF through it. I downloaded the Apparat source (where TDSI is part of) from Google Code and compiled it. Built another little Ant script to use TDSI with Ant. Just specify the input and the output file and you’re done!

Bringing it all together

All the above Ant scripts are saved in a separate file. This way I can import whatever piece I want in my build script, example:

  1. <import file="as3_version.xml" />

TIP: Place the import after you have defined your properties in the build script, this way the imported scripts can use the properties set in the build script.

Links

Flex PMD

Nice! A Flex (automated) auditing tool! 🙂

FlexPMD is a tool that helps to improve code quality by auditing any AS3/Flex source directory and detecting common bad practices

Would be interesting to start using this.

Gotcha:
The PMD Violations Viewer only accepts files that are named “pmd.xml”, all other files will not be recognized. I run an Ant task to rename the generated pmd.xml to pmd_[insert timestamp here].xml. When I tried uploading the renamed file the PMD Violations Viewer wouldn’t accept it. 🙁

Links: