14 March 2012
This article is intended for advanced developers with knowledge of Flash Builder or Flash Professional. You'll also need to know how to work with the command line on Mac OS X or Windows.
Additional required other products
Advanced
One of the issues you run into in game development on the Flash platform is how to combine the numerous SWFs that make up your game into a single SWF for iOS deployment. As an example, Machinarium, a point-and-click puzzle game developed by Amanita Design, has 28 SWF files. When Amanita Design used Adobe AIR to produce the iPad version of Machinarium, they needed a way to join the multiple SWF files into one (see Figure 1).
In my article Using SWC files to build large Flash and AIR projects with multiple SWF files for iOS, I covered a technique that relies on SWC libraries to address this issue. In some cases, however, you may prefer to keep using SWFs instead of SWC files. If your game will run on Android as well as iOS, for example, your workflow may be more straightforward with SWFs. Remember that on Android, you can load SWF files at runtime, which enables efficient memory usage. On iOS you also have to keep memory usage in mind, especially when you have all your code in one SWF. It is a good practice to separate any assets that do not contain ActionScript (including pictures, videos, and music) into SWF files, which your game can load on demand and then discard when no longer needed.
After you've separated out your assets, you still need a way to join the SWFs that do contain ActionScript. In this article, I describe the technique used by David "Oldes" Oliva, lead developer of Machinarium, for joining SWFs together using a REBOL script. For more information on REBOL, visit http://www.rebol.com.
Follow these steps to join SWF files in preparation for deploying your game on iOS:
cd ./public/
adl Game.xml
Change them as follows:
cd ./public/
[/path/to/your/AIR_SDK]/bin/adl Game.xml
import-swf lines to reflect the SWFs you want to combine. The initial example joins four SWF files:import-swf %assets/Preloader.swf no show
import-swf %assets/ExampleLevel1.swf no show
import-swf %assets/ExampleLevel2.swf no show
import-swf %assets/ExampleMain.swf no show
rebol command below to where you installed it.)/path/to/REBOL/rebol compile-and-run.r
Note: If you see a permission denied error when you try to run any of the executable files, make sure the files have the proper permission settings. You can set the permissions using chmod , for example (substitute 755 or 775 for a more restrictive setting):
chmod 777 filename.bat
adt tool included in the AIR SDK to compile the final IPA file for iOS. For example, you can run the following at the command line, replacing the bracketed sections as appropriate:[AIRSDK]/bin/adt -package -target ipa-app-store -provisioning-profile [YOURPROFILE].mobileprovision -storetype pkcs12 -keystore [YOURCERTIFICATE].p12 -storepass [CERTIFICATE_PASSWORD] [FINALAPP].ipa air-app-descriptor.xml [SWFTOCOMPILE].swf
If you think the SWC approach may better meet your needs, see my article Using SWC files to build large Flash and AIR projects with multiple SWF files for iOS. To learn more about REBOL, see the REBOL Quick Start. If you are interested in the main rules for Rebol/Flash Dialect (RSWF), Oldes has documented them here. Lastly, if you want to see what a small, independent game development studio can do with the Flash Platform, visit Amanita Design.
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.
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 |