Simple way to unload/reload swf in iOS.
Copy link to clipboard
Copied
I'm trying to find a way to completely reload/restart my app at the end or use a seperate collection of swf files when creating an AIR iOS app in Flash Professional. I used a UIloader in flash with a simple preloader before the simple app that I've made but I get the warning "ActionScript contained in externally loaded SWF files will be ignored on iOS devices."
My app works perfectly the first time through, but seems to encounter problems when played a second time, even if all the eventlisteners are removed. I'd like to completely refresh the app when it's played through a second time, either by unloading the main swf and switching to a preloader like I have previosly tried, or by seperating each scene into an easily loadable swf.
Is there an AIR compatible alternative to the UIloader component, or something similar that would allow me to use external swf files with actionscript?
Thanks for any help.
Copy link to clipboard
Copied
Hi,
I'm having issues with this issue also.
It seems Adobe didn't document so well all the limitations for exporting an application to iOS.
When they sold me the Flash CS6 I was told something like "seamless ios and android building platform".
Did you manage to solve your issues?
Copy link to clipboard
Copied
If you're not already doing so, you should give AIR 3.8 a try. Some of the loader issues and warning messages have been taken care of. Also, you'll get warnings about your app not being PIE complient, which doesn't mean it will be rejected. But, using AIR 3.8 will solve that issue too.
For the general approach of having modules that load and unload, we use SWCs. Each module can be tested as a SWF, but we have the publish settings set to make a SWC and a SWF. A quick command-return (or control-enter) test movie will be all it takes to update the SWC. Then we can test the main app FLA, and it will use the updated SWC.
Working that way gives us the same flexibility as we would get with loading external SWFs, and we don't have to worry about using loaders.
Copy link to clipboard
Copied
Hi,
thanks for the reply.
I have a Class called "ScreenManager.as" that handles loading and inside the "onComplete function" for the loader, I set the eventlisteners etc for each swf I load.
If I use SWC's instead, where would I handle each file? How do you load/unload? How do you add listeners?
Thanks man
Copy link to clipboard
Copied
And by the way, started earlier today using AIR 3.8
Copy link to clipboard
Copied
SWCs would be added in the ActionScript settings of your main FLA. Suppose you had one that was called Game1.swc, and its document class is called Game1Main.as, in your main FLA you would have code like this:
var currentgame:MovieClip;
currentgame = new Game1Main() as MovieClip;
You can then add listeners to it just like you would have by getting the content of a loader.
One tricky thing though, the document class of your main FLA will need to know about the class names of the SWCs. That can easily be handled by just mentioning the class names in your main FLA class. For example, to know about three games you might load later, you could have this line:
That’s enough to let the compiler know about those classes.
Copy link to clipboard
Copied
Alright, did all that and now I'm having the following issue:
ReferenceError: Error #1065: Variable XXX is not defined.
This is happening for instance names I have given to movieclips in the stage of the exported SWCs..
Copy link to clipboard
Copied
You would want to use the “automatically declare stage instances” option in the ActionScript settings. Also, make sure that the same named instances in different SWCs are truly identical.
For cases where in the SWC you are adding things from the library at runtime, you need to list those library classes in the main FLA too.
