AIR modules + iOS - ios

We are building a large-scale app with AIR for iOS.
One constraint of an AIR app with the iOS packager is that there are no modules. It is possible to load SWF files, but any embedded actionscript code is ignored.
We are wondering what happens to an AIR app for iPad when the code size gets very large. Are you aware of any technique for dividing code up into logical load groups, or do app developers just rely on virtual memory to swap in only a subset (hopefully) of the entire binary image?

No, AIR does not allow package more than one primary SWF.
We have a quite large project and wanted to use modules as well.
Solution we ended up with was removing all embedded sources. That includes graphics and sounds libraries created by Flash IDE or [Embed] classes.
All resources are loaded at runtime using
Sound.load() for mp3/sounds
Loader.load() with asynchronous image decoding policy for png/jpeg/images
FileStream.openAsync() for other/binary data.
We had 36 MB SWF file, now it is only 1.4 MB plus all the external assets.

Related

Does building a binary using Expo compress the size of an application?

I'm getting ready to deploy my react native application to the iOS App Store, and am going to build a binary using expo (something I've never done before). However, something that has confused me since I started this project is why my application folder is so big. My app has maybe around 40 images, most smaller than a few hundred kb. However, the node_modules folder is pretty large and makes up the bulk of my application folder with about 150mb of packages, most of which I don't use and the ones I do using only contributing to a fraction of that total. When I build a binary, will those unused packages be included in the binary or will it be much smaller than it is right now? If it will still be around the same size after building, how can I significantly shrink the size of my application?
No, it will not be included in the bundle. In my experience, a basic React Native app is roughly 7-11MB. Yours will of course be larger if you have a ton of components and static assets, but it's nothing to worry about.

Why does my iOS app compress so well?

I'm baffled by how Xcode is managing to compress my iOS app so effectively. All of my images and sound files combined add up to 282 MB for about 3000 items. However, the .app is somehow only 126 MB! Further, the file sizes inside the .app package contents are the same, yet the folder sizes are all roughly half size. How is this possible?
The main reason is probably that all your images (assuming images make up the majority of the 282 MBs in your app) are compressed using pngcrush as a build step in your application. You can actually watch this by looking at at the build log from xcode.
The special version of pngcrush that is used in the iOS SDK cause the PNG images to be non-standard (making them unviewable on the Mac or any other standard program for that matter). Instead, they are adapted to the display hardware of the iOS devices which means that they will load faster as well.

Is it possible to embed an existing SWF into an Air for iOS app?

One of my customers has many SWF and he would like to port them to iPad. However, he only has the SWFs, not the FLAs.
I 'd like to know if it is a way to run the SWFs inside an Air for iOS app. I´ve read you can import then with a Loader, but they will only run as an animation ignoring all the code inside them.
Thanks, any help is welcome!
[UPDATE] I´ve read something about using SWC, but still not sure if they will run the code.
Update, Oct 2012:
In Adobe AIR 3.5, adl is introducing a feature called "multiple SWF support" that allows the use of Loaders to load SWFs delivered in the .ipa (local files, not from servers) to have code in them. The adl compiler AOT compiles SWFs that are included in the .ipa, allowing them to be loaded and work under iOS.
AIR 3.5 is currently in beta at the time of this writing, available on the adobe labs site:
AIR 3.5 on Adobe labs website
AIR 3.5 release notes
Note that this feature requires -swf-version=18 or greater of the root SWF (not necessarily the assets being loaded) and AIR namespace ending in 3.5 in the application xml file.
Older answer:
The reason external SWFs with code in the doesn't work is that Air's ADT compiler cross-compiles your root SWF (and only your root swf) into objective-c code consumable by an iOS device. Both [embedded] SWFs and those included in the .ipa (prior to AIR 3.5) are not cross-compiled.
I created a workaround for this problem for embedded assets:
[Embed(source="gameLevel.swf")]
private var gameLevel:Class;
...
addChild(new gameLevel());
In this scenario, if gameLevel.swf has code in it, it typically wouldn't work in iOS, because new gameLevel() would create a Loader and interpret SWF bytecode. But, if you first run the above SWF through my tool called SWFMerge, it will take your embedded SWF and merge it into your root SWF. The result is that ADT will compile your embedded code into objective-C, it will work on iOS, and note: new gameLevel() now results in an instance of your asset - NOT a Loader.
The SWFMerge tool is here:
http://www.onetacoshort.com/temp/SWFMerge_alpha.swf
LMK if this workaround works for you or if you have trouble. Cheers!
-Jeff
Yes you can,
Apple does not allow your application to download SWF's using Loader from the internet but you ARE allowed to embed and include them inside of your .ipa
To do this you would use the embed tag
[Embed("myswf.swf", mimeType="application/octet-stream")] private var mySwf:Class;
You can then use
swf = new mySwf();
swf.addEventListener(Event.COMPLETE, completeHandler);
And interact with the swf inside that complete handler
I wanted to add to this that it is possible to compile a SWF that is not able to be loaded

Flash builder 4.6. How to reduce the mobile app size for IOS.

I have build an app and its in app store aswell. But the app size is more than 20 mb so it can not be downloaded with out wifi or connecting to computer. How can I reduce the app size? I have unziped the ipa file and checked but there is nothing big which can be reduced. So is there a way to compress it more or do some trick to reduce the size of app.
Under i added some of the ways that used in Flash Builder to optimize and reduce Build Size.
If you use custom components make them Model and load through Model Loader.
If you are using Flex Builder or the mxmlc command-line compiler, you can set the
optimize compiler option to true
mxmlc -optimize=true MyApp.mxml
3.When you set the strict compiler option to true, the compiler verifies that definitions
and package names in import statements are used in the application.
4.Implement RSL in your Project - Runtime Shared Libraries
5.Create SWC file of your common code

Convert Flash to iOS app

For the record, I am an iOS developer, and have absolutely no background on how flash programs work/run/developed...etc.
I have a Flash program that is mostly a collection of SWF files. It does, however, contain some Actionscript, Javascript and other integrated languages here and there..
I would like to convert this project/program to an iPad application. Is it possible?
What I got from searching the net:
Converting Actionscript to LUA script
Using Corona SDK to port the program to iOS
Starting a new iOS project in flash and moving the code somehow..
Other tedious ways which are not feasible at all....
The above mostly handles the actionscript part .. what about the SWF files?
As a last resort, one could at least guide me to a developer/company who can handle this task, or provide training to accomplish this.
Additional details
The flash program app file is already generated, and the program works on desktops perfectly. The program is somehow an interactive e-book, and it has some linked XML files to index the table of contents and other sections...
I've not done a lot of iOS development yet, but here are my experiences so far; maybe they help you form a better idea.
Only the main SWF can contain actionscript code.
I'm not sure how far assets (Sounds, Fonts, MovieClips) in other SWFs which are exported for actionscript are accessible to the main SWF.
It is possible to include additional XML files (and other types) which can be loaded via the normal loader classes.
Recently I came acrosshe tool which allows you to convert and play swf to some cross-platform frameworks. Now they support only Cocos2d-x, Unity 3d and Starling. But I saw the logo of Corona on their homepage. You can go there and ask them. I don't remember the right name of the site, but tool is called GAF converter

Resources