Copy link to clipboard
Copied
Hi Community,
I am creating an app in AS3.
One of the things I am doing is I am loading several swfs from outside my app.
I can load and unload them using the action scrip:
tourdoc.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF);
import fl.display.ProLoader;
var fl_ProLoader:ProLoader;
var fl_ToLoad:Boolean = true;
function fl_ClickToLoadUnloadSWF(event:MouseEvent):void
{
if(fl_ToLoad)
{
fl_ProLoader = new ProLoader();
fl_ProLoader.load(new URLRequest("swfs/tour.swf"));
addChild(fl_ProLoader);
}
else
{
fl_ProLoader.unload();
removeChild(fl_ProLoader);
fl_ProLoader = null;
}
// Toggle whether you want to load or unload the SWF
fl_ToLoad = !fl_ToLoad;
}
and it works fine, although I need a close button to unload each swf.
Is there any easy way to do it?
Thank you all
Best Regards
Ana
import fl.display.Proloader;
var proloader:Proloader=new Proloader;
var urlReq:URLRequest = new URLRequest("swfs/tour.swf");
load_button.addEventListener(MouseEvent.CLICK,loadF);
unload_button.addEventListener(MouseEvent.CLICK.unloadF);
function loadF(e:MouseEvent):void{
proloader.load(urlReq);
addChild(proloader);
}
function unloadF(e:MouseEvent):void{
proloader.unload();
removeChild(proloader);
}
Copy link to clipboard
Copied
Any help here? pleassssseeeeeeeeeeee 😉
Copy link to clipboard
Copied
It would help if we could figure out what you're asking.
Copy link to clipboard
Copied
what's wrong with the unload() method?
Copy link to clipboard
Copied
Sorry, if I am not explaining right. I will try better...
So, I would like to use one button to load the SWF and a diferent one to unload the same SWF, like one button to open a window and a close button. Somehow it is not working the way I am doing it. I am not able to unload the SWF unless I press it twice. Probably I am doing something wrong...
Sorry for bothering you with my nonsense...
Copy link to clipboard
Copied
import fl.display.Proloader;
var proloader:Proloader=new Proloader;
var urlReq:URLRequest = new URLRequest("swfs/tour.swf");
load_button.addEventListener(MouseEvent.CLICK,loadF);
unload_button.addEventListener(MouseEvent.CLICK.unloadF);
function loadF(e:MouseEvent):void{
proloader.load(urlReq);
addChild(proloader);
}
function unloadF(e:MouseEvent):void{
proloader.unload();
removeChild(proloader);
}
Copy link to clipboard
Copied
Thank you for your answer.
It makes sence to me, just getting this two errors:
Scene 1, Layer 'Actions', Frame 1, Line 13, Column 49 1119: Access of possibly undefined property unloadF through a reference with static type String.
Scene 1, Layer 'Actions', Frame 1, Line 13, Column 49 1136: Incorrect number of arguments. Expected 2.
Thank you for your patience.
Copy link to clipboard
Copied
there's a typo in line 2. the last period should be a comma:
unload_button.addEventListener(MouseEvent.CLICK.unloadF);
should be
unload_button.addEventListener(MouseEvent.CLICK,unloadF);
Copy link to clipboard
Copied
YES!!!
Working now!!!
You can't imagine how many times I looked at the code to see if there was something wrong...
Thank you very much
Copy link to clipboard
Copied
you're welcome.