Copy link to clipboard
Copied
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.
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]
Copy link to clipboard
Copied
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]
Find more inspiration, events, and resources on the new Adobe Community
Explore Now