Skip to main content
Participant
December 8, 2013
Question

iOS app using Air 3.9 - how can we reload a swf that was previously loaded?

  • December 8, 2013
  • 2 replies
  • 1798 views

We are developing an iOS app using the air 3.9 sdk. Our application is such that we have 2 SWFs packaged inside the ipa file i.e.the main.swf and an experience.swf.
The main.swf is loaded initially using application.xml. A button-click within the main.swf loads the experience.swf (which is located within the bin folder in the ipa, NOT remotely downloaded). This experience.swf contains assets and code.

When we create an ad-hoc build, experience.swf loads perfectly the first time, but if the user returns to the main.swf and then tries loading the experience.swf again, it doesn't load. Just the default stage color is visible. (This problem only occurs on the ad-hoc build. The debug build has no such issues)


To load this experience.swf we are using the flash.display.loader with loaderContext set as the ApplicationDomain.currentDomain.

mcExperience = new MovieClip();

var url:URLRequest = new URLRequest("ChristmasExperience.swf");

var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);

loader.load(url, loaderContext);

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, CompleteHandler);

addChild(mcExperience);

private function CompleteHandler(e:Event):void
{
trace("I HAVE LOADED .... SWF loaded... , waiting for the constructor call back..." + e.target.loader.content);
//mcExperience.addChild(loader);
mcExperience.addChild(MovieClip(e.target.loader.content));
//TODO : Set the Session ID Here
m_experienceBase.SetSessionID(int(m_ExperienceSessionID));
m_experienceBase.SetLocalPlayer(m_localPlayer);
//(loader.content as MovieClip).soundTransform = new SoundTransform(0);
//addChild(loader);
//setChildIndex(m_tfConsoleMsgDisplay, numChildren - 1);
}

When the experience is unloaded, we remove the holder MovieClip of the experience.swf and unload the flash.display.loader. This still does not re-load the previously loaded experience.swf.

if (mcExperience)

{

mcExperience.removeChildren();

removeChild(mcExperience);

mcExperience = null;

}


We are using swf-version=22 for both main and experience swf.

This is quite a big problem for us and we've gone through a bunch of posts, to help understand this issue better (a few examples below):

http://stackoverflow.com/questions/20039377/adobe-air-ios-and-multiple-swfs-returning-to-a-previously-loaded-swf

http://stackoverflow.com/questions/19536000/load-and-reload-external-swf-in-air-for-ios?lq=1

http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-multiple-swfs-in-air-apps-on-ios/

Is there any way to reload a secondary swf within an ios application?

This topic has been closed for replies.

2 replies

Known Participant
February 26, 2014

I was able to solve the problem of reloading SWF's w/o ABC (no code!), I explain it all on my blog (http://www.eqsim.com/blog/?p=400) but also simply give the code on StackOverflow: http://stackoverflow.com/questions/19536000/load-and-reload-external-swf-in-air-for-ios/22046009#22046009

Inspiring
December 9, 2013

Apparently you can't. Check out this page, the SWF reloading section. I was struggling was this same problem for two weeks until I completely changed my app to just not need to load external SWFs. It turns out it was for the better.

http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-multiple-swfs-in-air-apps-on-ios/

Colin Holgate
Inspiring
December 9, 2013

The link you gave was the same link that had already been given, and that points to an article about AIR 3.6.

I’m not sure if AIR 3.9 has changed fundamentally with regard to this problem though, but here’s a work around someone used, to make the subsequent loads seem like a new file:

https://gist.github.com/sportebois/6969008

Would it be possible to just keep a reference to the loaded swf, after the first load? Then you can removechild it when you’re not needing it, and addchild it back when you do need it.