Archive for the 'Flash' Category

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

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

Running Adobe AsDoc on my Mac using ANT!

Wow, this was really challenging! But now, finally, I found out how to use AsDoc on my Mac.There must be another solution out there, but I simply want to document this workaround hoping that this also works on your Mac.

What you need is a Flex SDK 2.0.1 which comes with Flex Builder or as a free download from Adobe and the knowledge how to use ANT (I use eclipse).

I tried this tutorial several times but it never worked for me. I don't know why.But after hours of testing I  hopefully found a proper solution which works find with Flex SDK 2.0.1. The main idea simply is separating the AsDoc functionality from the normal Flex Builder environment. Basically the only thing you have to do is avoiding whitespaces from your directory names. However I tried to use Flex Builder for this and Flex Builder installs into the directory "Flex Builder 3".So this is what I did and you might try:

  •  Create a new directory within the applications folder (don't use whitespace!) "Applications/Adobe_AsDoc"
  • Copy the Flex SDK 2.0.1 into that "Adobe_AsDoc" directory
  • Rename the Flex SDK directory to "FlexSDK_201" (which might not be necessary, but I tried to avoid any special characters within the directory names)

Great. So all you have to do now is download and use this ANT build.xml (download):

XML:
  1. ?>?>?>
  2.  
  3. <project default="asdoc" name="Documentation">
  4. <property environment="env"></property><!--
  5. Markus Raab - derRaab.com / superclass.de
  6. This ANT build.xml works on a Mac with a FLEX SDK 2.0.1 in the following location:
  7. /Applications/Adobe_AsDoc/FlexSDK_201
  8. For more informations see: http://blog.derraab.com/2007/11/23/running-adobe-asdoc-on-my-mac-using-ant/
  9. ATTENTION: Use relative paths (according to this build.xml)
  10. -->
  11.  
  12. <!--
  13. ActionScript directory location in source-path and doc-sources (both are needed?)
  14. -->
  15.  
  16. <property value="../src/as/" name="source-path"></property>
  17. <property value="../src/as/" name="doc-sources"></property><!--
  18. List with all your used library SWC files (using a directory causes asdoc not to write any documentation files?)
  19. -->
  20.  
  21. <property value="../src/as/mdm.swc ../src/as/layout.swc" name="library-path"></property><!--
  22. Documentation output directory
  23. -->
  24.  
  25. <property value="./classes" name="output"></property><!--
  26. SDK Location (without whitespace!)
  27. -->
  28.  
  29. <property value="/Applications/Adobe_AsDoc/FlexSDK_201" name="flex-sdk"></property><!--
  30. Location of the asdoc templates
  31. -->
  32.  
  33. <property value="${flex-sdk}/asdoc/templates" name="templates-path"></property><!--
  34. run
  35. -->
  36. <target name="asdoc">
  37. <exec executable="${flex-sdk}/bin/asdoc">
  38. <arg value="-source-path ${source-path}"></arg>
  39. <arg value="-doc-sources ${doc-sources}"></arg>
  40. <arg value="-library-path ${library-path}"></arg>
  41. <arg value="-output ${output}"></arg>
  42. <arg value="-templates-path ${templates-path}"></arg>
  43. </exec>
  44. </target>

AVM1 _globals are still global.

This is one of this quicknotes just for not forgetting a simple issue:While developing a "AS2Wrapper" for embeding AS2 contents in AS3 applications I recognised that _globals within the loaded AS2 SWFs still exist when you unload this SWF and load another. This seems to be quite apparent but I thought about the AVM1 as some kind of sandbox.

FOAM Rigid Body Physics Engine Alpha

Wow again! Drew Cummins recently released a alpha version of his FOAM calles physics engine. You definitely should check it out here. It runs really stable...

ActionScript Performance Test

This performance test shows how fast the ActionScript AVM2 runs compared to the AVM1, Java(!) and JavaScript: See it

Adobe MAX Chicago - Pacifica Sneak Peek

Wow! I found another great Sneak Peek. Imagine you integrate your own skype like service on your website which enables costumers to call you on your cellphone using this little app. Great: Video

Adobe MAX Chicago - Flash on C Sneak Peek

Today I found a real interessting Sneak Peak Video about porting C / C++ or other librarys to ActionScript 3. This will make a lot of librarys available to ActionScript 3 without rewriting anything. Thing about different file formats and stuff like that! Great possibilities! Watch the video here.

Video - Aral Balkan talk on Flashforum Konferenz 2007

I really enjoyed Arals talk on the Flashforum Konferenz about SWX this september. And now you can also enjoy it right here. He's a great guy!