Select and access local SWF files within an AIR application

Well, it took me a little time to figure out how to select and load a local SWF file into an SWFLoader instance. Several times I got this error message:

“SecurityError: Error #3015: Loader.loadBytes() is not permitted to load content with executable code.”

After some research I found this "dreaming in flash" blog entry which basically contains the solution I was looking for.

But then it took me a little more time to figure out how to use this with the SWFLoader. So here is a basic code example:

Actionscript:
  1. import flash.display.Loader;
  2. import flash.filesystem.File;
  3. import flash.filesystem.FileMode;
  4. import flash.filesystem.FileStream;
  5. import flash.system.LoaderContext;
  6. import flash.utils.ByteArray;
  7. import mx.controls.SWFLoader;
  8.  
  9. // File reference
  10. var swfFile: File;
  11.  
  12. // Open the SWF file
  13. var fileStream: FileStream = new FileStream();
  14.     fileStream.open( swfFile, FileMode.READ );
  15.  
  16. // Read SWF bytes into byte array and close file
  17. var swfBytes: ByteArray = new ByteArray();
  18.     fileStream.readBytes( swfBytes );
  19.     fileStream.close();
  20.  
  21. // Prepare the loader context to avoid security error
  22. var loaderContext: LoaderContext = new LoaderContext();
  23.     loaderContext.allowLoadBytesCodeExecution = true; // that's it!
  24.    
  25. // Now you could use this with a Loader instance
  26. var loader: Loader = new Loader();
  27.     loader.loadBytes( swfBytes, loaderContext );
  28.    
  29. // Or you could use this with a SWFLoader instance
  30. var swfLoader: SWFLoader = new SWFLoader();
  31.     swfLoader.loaderContext = loaderContext;
  32.     swfLoader.source = swfBytes;

Grant Skinners 50 reasons why AS 3 kicks ass

I found great slides on Grant Skinners blog. They give a quick introduction in AS 3 and it's core benefits!

50 reasons why AS 3 kicks ass (Grant Skinner)

Also a must read for developers!

Update: And he also added more slides from a workshop here

Microsoft Word error during HTML import

Since I have to use Microsoft Word 2008 for Mac I figured out some issue: During opening a clean XHTML file with external CSS declarations Word can find these CSS files only in the same directory. I tried serveral ways to declare the href tag, but only the last one works...

HTML:
  1. <link href="../style.css" rel="stylesheet" type="text/css" />
  2. <link href="./../style.css" rel="stylesheet" type="text/css" />
  3. <link href="..\style.css" rel="stylesheet" type="text/css" />
  4. <link href="style.css" rel="stylesheet" type="text/css" />

Maybe there is a solution? I can't figure it out.

Adobe Flash Player 9 Security Changes

As a developer you should definitely have a look at this paper

Flash Player GarbageCollection Problem

Grant Skinners post about the (for me) unknown problem with the Flash Player GarbageCollection is definitely a must read!

One of my projects also has problems with external loaded contents wasting memory.

Adobe technology platform RIA guide

This is simply the link list contained in the recently released Adobe technology platform ActionScript Reference PDF.

API References

Documentation

Developer Centers

Downloads

Miscellaneous Resources

Mailing Lists

Forums

Adobe should make some noise

I really love the work of André Michelle and Joa Ebert, especially if it's about some cool audio stuff! But the Flash Player doesn't provide enhanced audio support, actually it seems to get worse.

So we all should support the Adobe, MAKE SOME NOISE campain!

Write with AIR applications to the application resource directory

AIR applications are not permitted to write to the application resource directory. This seems to be a security feature and makes sense, because some systems would not allow to write into this directory at system level.

But for testing purposes you might hack this by using a single line of code:

Actionscript:
  1. // Writing into that file would fail
  2. var yourFileInAppDir: File = File.applicationDirectory.resolvePath( "yourFile.xml" );
  3. // This is the simple hack:
  4. yourFileInAppDir = new File( yourFileInAppDir.nativePath );

But this only avoids a AIR security error! You must be sure to have write access to the directory!

Are you Singularity?

Find out:

Singularity?

Adobe Creative Suite is calling mummy

Just a quick note: http://www.heise.de/newsticker/meldung/101258

Adobe products are calling 2O7.net (192.168.112.2O7.net) and send statistics. Visit 2O7.net to disable this.