Traditionally flash developers have been more focused on the browser to deliver their content. While delivering the content through the browser, developers generally embedded their assets within the root swf. Honestly, there is no other way except loading these images off their servers but this could have resulted in a lag whilst the content was running
With AIR however, developers need to make certain changes to their applications to make them more apt for deployment on mobile devices. With AIR, developers get access to the file system and the assets for their content can be accessed off the file system instead of being embedded within the root swf. Assets for the application should be packaged along with the application and then should be accessed on demand by simply loading them using a Loader.
On iOS, the swf file is converted in native arm code. For any application it is always preferred to have a small executable. A small executable has a lower memory footprint and a lower load time.
Let us talk a little more about assets. Assets can be broadly classified into two categories
1) Assets that do not contain ActionScript byte code (abc)
Under this header we can consider all media files, xml files, database files that do not contain any code. For using such assets, it is imperative that such assets are not embedded within the swf but should be loaded on demand using the Loader class. SWF files that only contain assets and do not contain any code should be loaded in a similar fashion. They should not be embedded as part of the root swf. Even the timeline animations created from Flash Professional should be loaded in the same way.
The easiest way to identify if your swf has code or not is to simply run swfdump on your swf and then search for a DoABC2 tag. The executable swfdump is available as part of the SDK.
FlexSDK/bin/swfdump mySWF.swf | grep DoABC2 (On MAC)
FlexSDK/bin/swfdump.exe mySWF.swf | find “DoABC2” (On Windows)
2) Assets containing ActionScript byte code (abc)
Under this header we can consider swf files that have any actionscript 3 code will fall under this category. Such files cannot be loaded at runtime and should be embedded using the Embed syntax
public static const myClass:Class;
Under this header I would also like to mention that certain workflows within Flash Professional might introduce actionscript code within a swf file without the developer himself typing in any code. One example would be exporting linkages for fonts. An AS developer may want to export a font from a swf file to be used later in some other swf. However, as soon as a linkage is created to be exported for Actionscript some AS code becomes part of the swf.
By not embedding assets within the root swf, developers keep the size of the executable smaller which goes a long way in keeping their application more performant. On demand loading of assets keeps the memory usage of the application lower. Rich content could have assets upwards of 50 MBs and keeping those assets permanently in memory unnecessarily keeps the memory usage of application high.
A smaller executable also keeps the load time of application lesser, thus enhancing the experience of your application.
Mobile devices have download, memory and performance considerations, and we strongly recommend that all mobile AIR apps try to keep their footprint below 50MB, where possible, to improve the user experience. Loading assets on demand is a simple technique that goes a long way in making performant applications.