Copy link to clipboard
Copied
My external SWF file plays fine until I add the remove on mouse event (SWF file loops until a button is clicked). When removeSwf is add the SWF stays on the first frame.
Any help would be wonderful - Thank you
var request:URLRequest = new URLRequest("PicLoop3working.swf");
var loader:Loader = new Loader()
loader.load(request);
addChild(loader);
addEventListener(MouseEvent.CLICK, removeSWF);
function removeSWF(e:MouseEvent):void{
removeChild(loader);
}
Copy link to clipboard
Copied
if you click twice that will generate an error and stop your app from doing anything else. of course, you may have other errors too, but to fix that one use:
var request:URLRequest = new URLRequest("PicLoop3working.swf");
var loader:Loader = new Loader()
loader.load(request);
addChild(loader);
addEventListener(MouseEvent.CLICK, removeSWF);
function removeSWF(e:MouseEvent):void{
if(loader.stage){
removeChild(loader);
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now