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

Are remote SWF faster than local SWF on AIR IOS app because I can 't use the unload code.

Explorer ,
Feb 27, 2016 Feb 27, 2016

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.

TOPICS
ActionScript
864
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

correct answers 1 Correct answer

Explorer , Mar 09, 2016 Mar 09, 2016

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

...
Translate
Community Expert ,
Feb 27, 2016 Feb 27, 2016

are you using unloadAndStop() instead of unload()?

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
Explorer ,
Feb 27, 2016 Feb 27, 2016

Packaging and loading multiple SWFs in AIR apps on iOS

Loader.unload() & Loader.unloadAndStop()

The behavior of Loader.unload() and Loader.unloadAndStop() on iOS is below. When either of these functions is called the following will happen:

  1. The contentLoaderInfo property of the Loader object will become null
  2. Any assets that are loaded with the secondary SWF will be unloaded.
  3. Any references to AS classes in the loaded SWF remain in memory, and new objects of those AS can be created. This is different from the behavior on other platforms.

Thanks voor the reply. But i didn't understand the answer because this information above is from the Adobe

blog.

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
Community Expert ,
Feb 27, 2016 Feb 27, 2016

use unloadAndStop().

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
Explorer ,
Feb 27, 2016 Feb 27, 2016

Oke thanks!! 

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
Community Expert ,
Feb 27, 2016 Feb 27, 2016

you're welcome.

if that solves the performance problems you see when unloading, mark that answer as correct or helpful.

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
Explorer ,
Mar 09, 2016 Mar 09, 2016

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.

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
Explorer ,
Mar 09, 2016 Mar 09, 2016

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

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
Explorer ,
Mar 09, 2016 Mar 09, 2016

thank you very much. I will try!

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
Explorer ,
Mar 15, 2016 Mar 15, 2016
LATEST

It doesn't work for me. I think the problem is the code that refer SWF1 to SWF isn't good.

It's terrible.

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