Using SWC files to build large Flash and AIR projects with multiple SWF files for iOS

Wednesday, March 7, 2012

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).

Figure 1. For iOS, first compile SWCs and then link them together to produce a single SWF file.
Figure 1. For iOS, first compile SWCs and then link them together to produce a single SWF file.

Creating a single SWF from SWCs


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.
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.
Figure 3. Select SWC under the Publish options in the Publish Settings dialog box.

Where to go from here


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, but not ActionScript 2.

~ 0 comments: ~

GuaBlog!

OhBelog!

Qoute from A's desk

Who walks the path of heaven will rule over everything... Bring the Peace, Keep the Peace, Walk in Peace then Rest in Peace...

Total Tayangan Laman

Followers

About Me

Recent Posts


ShoutMix chat widget

Link

Blogger Widgets
Related Posts Plugin for WordPress, Blogger...

Please help pay cup of coffee for us~

abrapism almawalker. Theme images by sndr. Powered by Blogger.

Popular Posts