Skip to main content
Known Participant
October 30, 2011
Answered

Using swf files compiled as swc in a ios project

  • October 30, 2011
  • 5 replies
  • 2491 views

Hi,

I might have a quite stupid question, but here I go anyway since its not easy on iOS.

I have 10 swf files (each file is 1 game with all assets + as3 inside it)

I'd like to make now an iOS app (air 2.7) which can play those 10 games on selection.

Normally on iOS its not allowed to load in swf files with AS3 in it because you may not use interpreter by Apple.

Now, on http://www.flashrealtime.com/compiling-big-air-swf-to-ios/ I read some info about a trick to use SWC.

Here is my question now.

If each of my 10 swf files actually contains 1 movieclip on stage which by itself contains all game logic (as3) and assets inside it, then can I compile these 10 swf files each one to a swc and somehow include them in a big iOS app ?

For example

in game1.swf the main movieclip would be on stage and would be exported for actionscript under the name "game1_mc"

in game2.swf the main movieclip would be on stage and would be exported for actionscript under the name "game2_mc"

in game3.swf the main movieclip would be on stage and would be exported for actionscript under the name "game3_mc"

in game4.swf the main movieclip would be on stage and would be exported for actionscript under the name "game4_mc"

...


Can I then somehow include all those swc files inside my 1 big application ?

And can I then somehow instantiate one of these movieclips and add them to the displaylist to start a game ?

This could solve a big problem for me, but I'm very unsure if thats possible.

Kind regards,

Bart

This topic has been closed for replies.
Correct answer Colin Holgate

In the end you have all those things included with the main file, and the tips on that page may be more geared towards Flex users. If you're using Flash, you could go to each of the FLAs and copy the movieclip from its library, and paste it into the main swf library. Set it to be shared for ActionScrtipt, and use a name that is unique. For example, you might set the shared symbol name to Level1. Then, in your main code, where you would normally load in the external swf, you just say:

var levelmc:MovieClip = new Level1();

addChild(levelmc);

That should work just as well as making everything be swcs.

5 replies

Colin Holgate
Colin HolgateCorrect answer
Inspiring
October 30, 2011

In the end you have all those things included with the main file, and the tips on that page may be more geared towards Flex users. If you're using Flash, you could go to each of the FLAs and copy the movieclip from its library, and paste it into the main swf library. Set it to be shared for ActionScrtipt, and use a name that is unique. For example, you might set the shared symbol name to Level1. Then, in your main code, where you would normally load in the external swf, you just say:

var levelmc:MovieClip = new Level1();

addChild(levelmc);

That should work just as well as making everything be swcs.

Known Participant
October 30, 2011

Thank you for this very fast reply. Just a little thought, but if I understand right you say that the swc method works but would be the same as copying the mc inside my .fla.

In that case, wouldn't it be better for project management to use the swc anyway, since flash doesn't have to recompile the stuff anymore each time you build?

Or is that advantage also not correct?

Also (and pardon me if this sounds extremely dumb) suppose I include 100 of those games and each game uses around 5MB, then I have 500MB of data in there. Will flash then by default use 500MB of ram on the mobile device (deadli and most probably not available) or will it only use the amount of ram neede by that 1 movieclip which we instantiate from the 100 available ones?

That would make a huge memory difference.

Colin Holgate
Inspiring
October 30, 2011

A swc is just a zip file of the swf, with its AS3 code intact, and that the compiling to iOS native code would still happen when you publish.