Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

Simple way to unload/reload swf in iOS.

New Here ,
Jun 12, 2013 Jun 12, 2013

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.

TOPICS
Development
1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 14, 2013 Jul 14, 2013


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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 14, 2013 Jul 14, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 14, 2013 Jul 14, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 14, 2013 Jul 14, 2013

And by the way, started earlier today using AIR 3.8

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 14, 2013 Jul 14, 2013

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:

var gameclasses:Array = ;

That’s enough to let the compiler know about those classes.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 14, 2013 Jul 14, 2013

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..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 14, 2013 Jul 14, 2013
LATEST

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.

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