Copy link to clipboard
Copied
Are remote SWF faster than local SWF on AIR IOS app because I can't use the unload code on AIR IOS .
my local code:
stop();
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream
go_level_2.addEventListener(MouseEvent.CLICK,level_2);
function level_2(event:MouseEvent){
var loader2:Loader = new Loader();
var loaderContext2:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
var file2:File=File.applicationDirectory.resolvePath("level2.swf");
loader2.load(new URLRequest(file2.url), loaderContext2);
addChild(loader2);
}
Because this works not for me, because i can't unload the SWF file en the app becomes slow, i will put the SWf''s on a remote place.
But I can't imagine what happens when i loaded the SWF file from remote. stays it on the server or stays it on my app when i unloaded it, and the app also becomes bigger. I hope you can help me because i went on the internet for a week and don't now how to go on further.
I had a similar problem, but not on iOS.
Maybe my solution could work for you too, though.
The problem was coming from this line:
new LoaderContext(false, ApplicationDomain.currentDomain);
Do not reuse the same application domain, or you'll never be able to get rid of the definitions, and therefore the loaded SWF.
Instead, make a new application domain, child of the current domain, keep track of it and dispose it along with the rest of the SWF when you're done.
Example :
var loader2:Loader = new Loader
...Copy link to clipboard
Copied
are you using unloadAndStop() instead of unload()?
Copy link to clipboard
Copied
The behavior of Loader.unload() and Loader.unloadAndStop() on iOS is below. When either of these functions is called the following will happen:
Thanks voor the reply. But i didn't understand the answer because this information above is from the Adobe
blog.
Copy link to clipboard
Copied
use unloadAndStop().
Copy link to clipboard
Copied
Oke thanks!!
Copy link to clipboard
Copied
you're welcome.
if that solves the performance problems you see when unloading, mark that answer as correct or helpful.
Copy link to clipboard
Copied
thanks for reply but i have the next problem:
go_level_2.addEventListener(MouseEvent.CLICK,level_2);
function level_2(event:MouseEvent)
{
var loader2:Loader = new Loader();
var loaderContext2:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
var file2:File=File.applicationDirectory.resolvePath("level2.swf");
loader2.load(new URLRequest(file2.url), loaderContext2);
loader2.addEventListener("LEVEL_2",true); |
addChild(loader2);
}
function finishLevel2(event:Event):void
{ var loader2:Loader;
loader2=event.target.loader; | |
loader2.parent.removeChild(loader2); | |
loader2.unloadAndStop(); |
}
//And the code in next level to remove level before add another.
var loader2:Loader;
function finish_game(event:Event):void
{
dispatchEvent(new Event("LEVEL_2",true));
}
I have a Main_SWF within 10 levels_SWF's.
I tried several codes but not one of these unload te previous game.
And the game begin slower and slower.
The last part of developing a game for IOS is a "nightmare" i think.
i test the code on iOS simulator.
I hope you can help me.
Copy link to clipboard
Copied
I had a similar problem, but not on iOS.
Maybe my solution could work for you too, though.
The problem was coming from this line:
new LoaderContext(false, ApplicationDomain.currentDomain);
Do not reuse the same application domain, or you'll never be able to get rid of the definitions, and therefore the loaded SWF.
Instead, make a new application domain, child of the current domain, keep track of it and dispose it along with the rest of the SWF when you're done.
Example :
var loader2:Loader = new Loader();
var appDomain2:ApplicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
var loaderContext2:LoaderContext = new LoaderContext(false, appDomain2);
var file2:File=File.applicationDirectory.resolvePath("level2.swf");
loader2.load(new URLRequest(file2.url), loaderContext2);
addChild(loader2);
Then
function finishLevel2(event:Event):void
{
var loader2:Loader;
loader2=event.target.loader; | |
loader2.parent.removeChild(loader2); | |
loader2.unloadAndStop(); appDomain2 = null; |
}
Note that the definitions of the loaded SWF's classes will only be available from the new application domain...
Copy link to clipboard
Copied
thank you very much. I will try!
Copy link to clipboard
Copied
It doesn't work for me. I think the problem is the code that refer SWF1 to SWF isn't good.
It's terrible.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now