By Tom Krcha
27 February 2012
27 February 2012
This article is intended for advanced developers with knowledge of Flash Builder or Flash Professional.
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-interpreterswitch 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).
Figure 1. For iOS, first compile SWCs and then link them together to produce a single SWF file.
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.
Figure 2. Select Flex Library Project, which creates a SWC file.
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).
Figure 3. Select SWC under the Publish options in the Publish Settings dialog box.
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
More Like This
- Multitouch and gesture support on the Flash Platform
- Designing for a multi-device, multi-resolution world
- Optimizing Flash performance
- Using the Adobe Flash Sprite Sheet Generator
- Optimizing performance for mobile AIR applications
- Optimizing content for Apple iOS devices
- Joining multiple SWF files into one SWF for iOS deployment
- Guide for Apple App Store submissions
- Saving state in AIR applications for iOS devices
- Creating mobile projects with the shared assets feature and the Project panel in Flash