loader.unload();
removeChild(loader as DisplayObject);
try that.
Printable View
loader.unload();
removeChild(loader as DisplayObject);
try that.
It still seems to freeze on the last frame of the loaded swf, maybe there is another way of going about the whole loading and unloading?
Post your FLA file if it's not too big I'll have a look at it.
Im not sure if this helps but i tried to repeat the exact thing with a new swf, one that contains no AS, only the event dispatcher on the last frame.
Now everything works fine and it unloads like it should but i get an Output saying this:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@1f380359 to flash.events.MouseEvent.
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio n()
at flash.events::EventDispatcher/dispatchEvent()
at test_fla::MainTimeline/test_fla::frame2184()
In the function removeSWF it still has a trace "test" but it seems to not trace it.
The only AS that was in the swf files i want to use, calls sound and has a simple pause and play button.
This shouldn't be. Post your code one more time, the way you have it right now.
Actionscript Code:var loader:Loader
function buttonClick(event:MouseEvent):void
{
loader = new Loader();
loader.x = -187
loader.y = -375
loader.load(new URLRequest(event.target.name + ".swf"));
addChild(loader);
loader.addEventListener("removeIt", removeSWF);
}
function removeSWF(e:MouseEvent):void
{
loader.unload();
removeChild(loader as DisplayObject);
trace("test");
}
test.addEventListener(MouseEvent.CLICK, buttonClick);
Clip2.addEventListener(MouseEvent.CLICK, buttonClick);
Clip3.addEventListener(MouseEvent.CLICK, buttonClick);
Clip4.addEventListener(MouseEvent.CLICK, buttonClick);
Clip5.addEventListener(MouseEvent.CLICK, buttonClick);
Clip6.addEventListener(MouseEvent.CLICK, buttonClick);
clip7.addEventListener(MouseEvent.CLICK, buttonClick);
function definition should read:
function removeSWF(e:Event):void
Ok so it works all fine now with my test swf but when i use my actual swf file it still freezes on the last frame, i deleted the buttons and everything from it, now it only contains words graphics and AS to call sounds like this on frame 2:
Actionscript Code:var s=new Sound();
s.loadSound("Narration/Section1aa.mp3", true);
and this on every other key frame:
Actionscript Code:stopAllSounds();
var s=new Sound();
s.loadSound("Narration/Section1ab.mp3", true);
It doesnt make sense to me.
I solved it, it was a stupid mistake.
I had a background layer folder that was closed and when I opened it to check, I had them extended to the same frame at the last frame that contains the even dispatcher.
I cut everything layer back a frame so that the last frame was the event dispatcher and it was completely blank.
This seemed to solve my problem. Thanks for all your help Beathoven.
Glad you finally got it figured. Make sure you mark the thread resolved (Top right, Thread Tools, Mark Thread Resolved)