I found several info on how to load one or more external SWF files, packaged with my AIR iOS App, the actual working code is:
var myUrlRequest:URLRequest = new URLRequest(mySWF);
var myLoaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
var loader: Loader = new Loader();
loader.load(myUrlRequest, myLoaderContext);
Object(root).MK.addChild(loader)
It works on Android devices and on Windows PC, but on iOS it loads the external SWFs only the first time. In my project I have several buttons that loads an external SWF, but each button works only the first time.
Any idea? It seems very unuseful if I can't reload an SWF.
A good way to handle this would be to load the SWF files into separate movieclips the first time and then when needing to "load" them anytime after that, just show those movieclips that already have the SWF files loaded in them.
I had problems loading SWF's even without code a second time. The solution I found depended on whether the code was from the application area (packaged with the app) or loaded externally (either from the web or downloaded into the caches folder). I wrote an extended post about here, if you're interested: http://www.eqsim.com/blog/?p=400 In a nutshell, here is my code for setting the path:
then here is my code for preparing the path, if the SWF is from the app area or otherwise (cache or web):
Finally, my loading statements:
and now I can load SWF's and reload them (more importantly). Of course the SWF's do not have bytecode in them.
If you can't load something a second time, perhaps it would be best to simply cache it and make a point of only loading it once?
You can't load a SWF file that contains any ActionScript ByteCode (ABC) then unload it and reload it on iOS. If you attempt to do this, the runtime throws error 3764.