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

Flex Builder issue

I keep on getting the following error:

Buildfile: C:\Projects\*****\flex\ant\build.xml
compile_main_debug:
[exec] Loading configuration file C:\flex3sdk\frameworks\flex-config.xml
[exec] Error: C:\Projects\*****\flex\bin-debug\main.swf (The process cannot access the file because it is being used by another process)
[exec] java.io.FileNotFoundException: C:\Projects\******\flex\bin-debug\main.swf (The process cannot access the file because it is being used by another process)
[exec]     at java.io.FileOutputStream.open(Native Method)
[exec]     at java.io.FileOutputStream.<init>(Unknown Source)
[exec]     at java.io.FileOutputStream.<init>(Unknown Source)
[exec]     at flex2.tools.Compiler.mxmlc(Compiler.java:283)
[exec]     at flex2.tools.Compiler.main(Compiler.java:53)

BUILD FAILED
C:\Projects\******\flex\ant\build.xml:44: exec returned: 1

Total time: 4 seconds

This occurs whenever Flex Builder fails to launch the application and you try to compile after that.

The only way to solve it at the moment is to close Flex Builder. When it’s closed the application gets actually launched in the stand alone Flash Player. Close the SA Flash Player. Start Flex again and compile.

Or just open up Windows Task Manager and kill FlashPlayer.exe.

Custom graphic for Google maps polyline

I’ve been looking into the question wether or not it is possible to use a custom graphic for polylines (and/or polygons) in Google Maps. The result so far is very promissing and the answer is yes!

Click to launch

NOTE: right click and save as.. then run, as the gmaps API key used is not for this domain.

The feet are taken from a MovieClip and repeated for the length of the line.

I’ve achieved this by implementing the IPolyLine and IOverLay Interface. It took quite some figuring out to determine what each function was meant to do.

TBC…

TODO:

  1. Multi point line
  2. Exact line fill
  3. Flag for toggling image stretching / repeating
  4. Fixing a bug with Event dispatching