2
votes

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):

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

2
Why are you reloading the secondary swf? Why not keep it in memory and add / remove child it when you need it? if(!mcExperience){ loadMcExperience();} else { return mcExperience; }Keith

2 Answers

0
votes

Don't know if you checked here: http://blogs.adobe.com/airodynamics/2012/11/09/packaging-and-loading-multiple-swfs-in-air-apps-on-ios/

Basically you cannot reload an swf on IOS and this is from Adobe's mouth.

To overcome this, Adobe came with a NOTE: "Note: Reloading of pure asset SWFs will work with AIR 3.7 builds which can be downloaded from here"
Pretty lame if you ask me
So what you must do? Well put the hole code as before in older air versions, in the first swf and use the second swf purely as graphic/animation resource.

While this is a big drawback, blame Adobe :D

0
votes

Eventhough it says reloading of pure asset SWFs (SWF's w/o ABC) will work with AIR 3.7, I found problems with 4.0. I had SWF's with no code that did not work, and I needed a solution. I answered how I did it here: Load and reload external SWF in AIR for iOS and more fully here: http://www.eqsim.com/blog/?p=400