Highlighted

Best practices for working with multiple swfs in AIR for ios.

Community Beginner ,
Dec 29, 2015

Copy link to clipboard

Copied

Making an app that contains multiple games in one and wanted to have a menu system to load the individual games as needed. I have read the articles/blogs/comments about air supporting load of multiple swfs but not reloading those swfs and not trying to rehash that with this post although I do hope Adobe fixes this as the current version of Adobe Air 20.0.0.204 still does not support reload of a swf. So at the moment my app will load all the swfs that make up the app and display them as the user selects them, hiding/removechild the others while not in use.

My ask of the community is how are you developers handling working with multiple swf loads and sharing of any best practices. For example:

-are your swfs to be loaded into the main swf starting out as air projects for IOS? As I had an issue testing the swf created for ios simulator testing and only got the swfs to work when the target was for the flash player vs ios.

-how are you dealing with screen detection with multiples swfs? Is your main swf that the loaded swfs being loaded into detect device size and load the appropriate swf or is your individual swfs detecting size and loading appropriate assets?

-to control size of swfs in device memory are you loading just the .AS  files that contain the code and having those .AS files load the required graphically assets when the .AS is selected?

-how are your individual swfs handling removing/adding listeners as needed?

Any best practices you can share would be appreciated.

TOPICS
Development

Views

418

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Best practices for working with multiple swfs in AIR for ios.

Community Beginner ,
Dec 29, 2015

Copy link to clipboard

Copied

Making an app that contains multiple games in one and wanted to have a menu system to load the individual games as needed. I have read the articles/blogs/comments about air supporting load of multiple swfs but not reloading those swfs and not trying to rehash that with this post although I do hope Adobe fixes this as the current version of Adobe Air 20.0.0.204 still does not support reload of a swf. So at the moment my app will load all the swfs that make up the app and display them as the user selects them, hiding/removechild the others while not in use.

My ask of the community is how are you developers handling working with multiple swf loads and sharing of any best practices. For example:

-are your swfs to be loaded into the main swf starting out as air projects for IOS? As I had an issue testing the swf created for ios simulator testing and only got the swfs to work when the target was for the flash player vs ios.

-how are you dealing with screen detection with multiples swfs? Is your main swf that the loaded swfs being loaded into detect device size and load the appropriate swf or is your individual swfs detecting size and loading appropriate assets?

-to control size of swfs in device memory are you loading just the .AS  files that contain the code and having those .AS files load the required graphically assets when the .AS is selected?

-how are your individual swfs handling removing/adding listeners as needed?

Any best practices you can share would be appreciated.

TOPICS
Development

Views

419

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 29, 2015 0
Adobe Community Professional ,
Dec 29, 2015

Copy link to clipboard

Copied

I use SWCs instead of SWFs. Each mini game is designed to be able to cope with a range of 16:9 to 4:3, and the shell SWF only has to load the SWC in the right position on stage.

The FLA that the SWC is made from does not have anything on the stage. In the library is a movieclip which is the entire mini game experience, and it has a linkage, "Game1", for example.

All of the SWCs are added in the ActionScript 3.0 Settings of the main app FLA.

When the main app wants to load game 1, it will simply say:

var currentgame:MovieClip:MovieClip; //declared at the top of the FLA document class

if(currentgame!=null){

   currentgame.destroy();//destroy is a public function in all SWC's movieclip's class;

   currentgame=null;

}

currentgame = new Game1() as MovieClip;

currentgame.x = 0;

currentgame.y = 0;

addChild(current game);

Something on those lines! That's just typed here, it isn't exactly how the code looks, but should give you the idea.

Working this way seems to be ok, I never have trouble reloading a game that has already been played.

One big advantage, over say having movieclips in the main FLA, is that the publishing time is quick, the SWCs don't have to be republished each time you make a change to the shell, or to an individual SWC.

BTW, I have the game modules in a different folder to the shell FLA, so I publish to a relative path that finds its way to the deploy folder of the main FLA. So, this would be the publish path for the game 1 SWC: ../../shell/deploy/game1.swc

When you do a test movie of an individual game, you would be looking at a temporary swf, but on each test movie you're also updating the SWC, and at any time you could immediately test the main app, and it would already have the new SWC in it.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 29, 2015 1
Community Beginner ,
Dec 29, 2015

Copy link to clipboard

Copied

Appreciate the comment @colinholgate. Your method sounds like it would be less of a memory hog than loading swfs with all the graphic assets. Would appreciate knowing other advantages you see to the SWC method. I saw an article on this topic dated back in 2012 and was not sure if I should view the multiple swfs load as an improvement since the ability to load multiple SWFs came out later. The article I read on the subject: Using SWC files to build large Flash and AIR projects with multiple SWF files for iOS | Adobe Develo...


If you can point me to more information on the subject I would be glad to read more about it.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 29, 2015 0
Adobe Community Professional ,
Dec 29, 2015

Copy link to clipboard

Copied

I suspect the SWC approach may be more demanding memory wise, though I'm not really sure how AIR handles SWCs that have not been invoked. It hopefully all amounts to the same thing.

To have external SWFs that have code in them I think you would have to use the special command line publish method, that strips out the AS3 and puts it into the main package. Normally you would then put the code-less swfs on a server somewhere, and set up some XML to let AIR know about them. I don't know if that folder of swfs can be local, and it's enough hassle that I've never tried to see if it would work. Any time you change any code in any swf, I think you would have to go through the command line publish again.

Aside from the much faster publish time, I'm able to share SWCs across multiple apps. For example, I have a series of story apps that all have exactly the same contents page, but they naturally have different story pages. There is only one contents FLA, and if I want to add a new feature I do it to that one file. When I test movie it also replaces the SWC that all seven apps are looking for, and immediate I have the new feature in all of the apps.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 29, 2015 1