27 February 2012
This article is intended for advanced developers with knowledge of Flash Builder or Flash Professional.
Advanced
When doing game development for Android or Blackberry Tablet OS with Adobe AIR, you can load SWF files on the fly at runtime; with AIR for iOS, there is no such option. On Android or Blackberry Tablet OS the code is interpreted from ActionScript bytecode, whereas for iOS all code must compiled from ActionScript bytecode to native bytecode as a single IPA file, which you can only create from a single SWF.
If your game has dozens of levels and each level is a SWF, then compiling for iOS can be a challenge. When you're in the game programming and testing phase of development, you can use ipa-test-interpreter switch in the compiler settings, and your game will run as it would on Android or BlackBerry Tablet OS. However, Apple will not accept games built using this approach in the App Store, so you need a different approach for your release build.
One solution is to compile each level to a SWC library, and then link all the SWCs into a single SWF file (see Figure 1).
If you're using Flash Builder, you'll need to use a Flex Library Project (see Figure 2), which outputs a SWC file, instead of an ActionScript project, which outputs a SWF.
In Flash Professional CS5.5, you can use an option in the Publish Settings dialog box to generate a SWC instead of a SWF (see Figure 3).
When you use the technique outlined in this article for your iOS game development, you'll need to instantiate new levels at runtime instead of loading them dynamically. Remember, it is possible to load SWF files on iOS, but the code inside them won't be interpreted. Loading a SWF in this way is useful for graphical assets such as animations or vector graphics. You can create a library full of symbols and simply pick the symbol that you want to use.
Lastly, note that this technique works for ActionScript 3.0, but not ActionScript 2.0.
For information on combining several SWFs into a single SWF, see my article Joining multiple SWF files into one SWF for iOS deployment.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
Flash User Forum |
More |
| 04/23/2012 | Auto-Save and Auto-Recovery |
|---|---|
| 04/23/2012 | Open hyperlinks in new window/tab/pop-up ? |
| 04/21/2012 | PNG transparencies glitched |
| 04/01/2010 | Workaround for JSFL shape selection bug? |
Flash Cookbooks |
More |
| 02/13/2012 | Randomize an array |
|---|---|
| 02/11/2012 | How to create a Facebook fan page with Flash |
| 02/08/2012 | Digital Clock |
| 01/18/2012 | Recording webcam video & audio in a flv file on local drive |