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

[AS3] erase Loaders if they exist ?

Community Beginner ,
Jul 30, 2018 Jul 30, 2018

Hello (excuse my bad english / I'm an ol french)

I load a lot of ".swf" during the main, like this :

var conteneurImage2:Loader = new Loader();

var image2:URLRequest = new URLRequest("test/intro.swf");

conteneurImage2.load(image2);

this.addChild(conteneurImage2);

I want to erase the loaders, like this

conteneurImage2.unloadAndStop();

removeChild(conteneurImage2);conteneurImage2 = null;

conteneurImage2.visible = false;

But sometimes, some loaders don't exist. I know I need to use the function "if", but I don't succeed. I try this

if (conteneurImage2)

{conteneurImage2.unloadAndStop();

removeChild(conteneurImage2);conteneurImage2 = null;

conteneurImage2.visible = false;}

or this :

if (conteneurImage2 != null;)

{conteneurImage2.unloadAndStop();

removeChild(conteneurImage2);conteneurImage2 = null;

conteneurImage2.visible = false;}

It doesn't work. The loader is not deleted.

I thank you very much.

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

Community Expert , Jul 30, 2018 Jul 30, 2018

use:

function removeLoaderF(ldr:Loader):void{

if(ldr){

if(ldr.content){

ldr.unloadAndStop();

}

if(ldr.stage){

ldr.parent.removeChild(ldr);

}

/* remove listeners if there are any

if(ldr.hasEventListener(whatever)){

ldr.removeEventListener(whatever,whateverF);

etc

}

*/

ldr=null;

}

[moved from Adobe Animate CC to ActionScript 3]

Translate
Community Expert ,
Jul 30, 2018 Jul 30, 2018
LATEST

use:

function removeLoaderF(ldr:Loader):void{

if(ldr){

if(ldr.content){

ldr.unloadAndStop();

}

if(ldr.stage){

ldr.parent.removeChild(ldr);

}

/* remove listeners if there are any

if(ldr.hasEventListener(whatever)){

ldr.removeEventListener(whatever,whateverF);

etc

}

*/

ldr=null;

}

[moved from Adobe Animate CC to ActionScript 3]

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