With the newly released AIR 3.2 SDK, you can take advantage of Stage3D and achieve (near) native performance on iOS devices. As an example, I get a steady 58 frames per second on an iPad 2 when rendering 400 Sprites with Starling (Sprite size: 81×140 pixels).
However, getting Flash ready to export to your iOS device and take advantage of Starling is a bit of a challenge. You need to overcome these two challenges:
- Overlay the AIR 3.2 SDK onto Flash CS 5.5
- Get your app to use the “direct” render mode, which is required by Starling
Step Two: Get Flash to use the direct render mode in iOS
Starling requires a render mode of “direct.”
Unfortunately, Flash CS 5.5 doesn’t currently support the ability to choose this render mode when building for iOS.
See here: http://screencast.com/t/bJicMLHPevq
The solution is a bit of a hack.
You need to alter your app’s XML file and then make the file read only for PC, or locked on a Mac.
- Open your Flash project’s XML file.
As an example, my FLA is called “starlingIpadTest.fla”, so the app XML file is called “starlingIpadTest-app.xml”.
See here: http://screencast.com/t/fwceyJ76iZ
- Look for the <renderMode> tag. Set the render mode to “direct” like so:
- Make the file read only (PC) or lock it (Mac).
You can now deploy your app and test it on your iPhone or iPad.
Getting the latest AIR SDKs to work with Flash CS 5.5 is a big pain. The following steps will save you some trouble. (This is for Win 7, but something similar should work for Mac, I suppose)
Note: As always, make backups of anything that you overwrite.
It would be foolish to try this without a way to undo these changes.
1. Download the latest AIR 3.2 SDK here:
2. Extract the SDK
3. Rename the parent folder “AIR3.2″
4. Place the “AIR3.2″ folder in <FLASH CS5.5 DIR>\
(on Windows 7, this is located here: C:\Program Files (x86)\Adobe\Adobe Flash CS5.5)
5. Create a directory named “AIR3.2″ in <FLASH CS5.5 DIR>\Common\Configuration\ActionScript 3.0\
6. Copy AIR3.2\frameworks\libs\air\airglobal.swc and paste it in the newly created <FLASH CS5.5 DIR>\Common\Configuration\ActionScript 3.0\AIR3.2 directory
7. Navigate to <FLASH CS5.5 DIR>\Common\Configuration\Players\
8. Paste in the XML files found in this ZIP file: flashAirXML.zip
9. Remove (back up to somewhere) any other iOS XML file that already exists in <FLASH CS5.5 DIR>\Common\Configuration\Players\
You can have multiple Android XML files here, but not iOS. I have no idea why.
You can now build to iOS with AIR 3.2 and take advantage of Stage3D!
My new HP Officejet 6500 Wireless printer comes with software called “HP Solution Center”. Apparently, the creators of this app didn’t use the debug version of the Flash Player when developing.
I just found a nasty little bug in Flash CS4. One line of code will result in a project that compiles with no errors and yet no trace statements work either.
Simply put the following line of code anywhere in your project (including in any class, or on any frame on the time line):
var version:Number = 0.0.1;
That’s it! Your project will (seem to) compile with no errors.
You won’t get any trace output either.
Imagine burying this line of code in a random class in a project that has hundreds of classes. How could anyone find it?
I’m Tellin’ Y’all It’s a Sabotage.
Modules are SWF files that can be loaded by an application but cannot run indepedently. Modules are built in to Flex 3, but it takes a bit of finagling to use modules in Flash.
I have been able to use modules successfully in Flash. Below are the steps to follow. I have also included the sample source code:
Grab the latest Flex SDK. I used 3.2:
In the Flash IDE (I’m using CS4), create a reference to the Flex SDK:
File > Publish Settings > Flash > Settings > Library Path
Add a reference to frameworks\libs (see the following image)
Advanced ActionScript 3.0 Settings
Create a module by creating a class that extends mx.modules.ModuleBase.
public class ModuleAlpha extends ModuleBase implements IModuleAlpha
public function ModuleAlpha()
public function addNumbers(a:Number, b:Number):Number
return a + b;
Compile the module using the mxmlc command line compiler.
Note: If you’ve placed your source in subdirectories, you will need to let the compiler know your source path.
In my example, ModuleAlpha.as is located in the com.electrotank.modules package.
Thus, here is my command to compile:
>mxmlc "-source-path+=../../../" ModuleBeta.as
Create a “parent” application that will load in your module(s) via mx.modules.ModuleManager.
Here is an excerpt from the sample code provided:
private const URL_MOD_ALPHA:String = "ModuleAlpha.swf";
_modules[URL_MOD_ALPHA] = ModuleManager.getModule(URL_MOD_ALPHA);
Create an instance of your newly uploaded module using the factory of IModuleInfo:
var modAlpha:IModuleAlpha = IModuleAlpha(IModuleInfo(_modules[URL_MOD_ALPHA]).factory.create());
Be sure to use your powers only for good and not evil.
When Flash introduced the copyPixel operation a few versions ago, I was very excited. Finally, I could create blazing fast games that worked more like “real” games instead of using MovieClips. However, copyPixel is no magic bullet.
Here are the results of a simple test where I scroll a background image. I guessed that copyPixel would yield the fastest results, but I was wrong.
Note that during initial testing it was difficult to get a big difference with an 800×600 drawing area.
Of course, that’s because I’m only moving 1 image around as opposed to hundreds as in an actual game.
Thus, to make the differences stand way out, I increased the drawing area to 1880×1024.
This will fill up Fire Fox if your resolution is 1920×1200, but you can still see the drawing area.
The frame rate is set to 120.
Note also that I am using a crazy big image of size 4095×4095 (3.5 Megs).
Various OSs and Browsers
||Fps Fire Fox - Win
|| Fps Internet Explorer - Win
|| Fps Fire Fox - Mac
||120 solid (wow)
||120 solid (wow)
So, the really confusing thing for me is that copy pixel seems to drag down gpu mode!
Also, remember when “opaque” used to be the best wmode option for performance? Not any more (at least for this specific test).