Question
remove externally loaded swf and tell parent swf gotoAndStop(1);
This is the code I use to load an external swf into a
movieclip. It works.
var thisMovieClip:MovieClip;
var myHBIMovieLoader:Loader = new Loader();
myHBIMovieLoader.load(new URLRequest("CBTs/HBI/CourseMain.swf"));
myHBIMovieLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, myHBIMovieLoaded);
function myHBIMovieLoaded(event:Event):void
{
thisMovieClip = MovieClip(myHBIMovieLoader.content);
stage.addChild(thisMovieClip);
thisMovieClip.addEventListener(Event.REMOVED_FROM_STAGE, removed)
function removed(event:Event):void
{
gotoAndStop("First");
}
}
gotoAndStop("CLCBlank");
As you can see on the last line of code, the main timeline moves to a labeled frame called, "CLCBlank." You can also see there is an event listener waiting for the external swf to be unloaded. It actually works, too, ONCE.
When I am done with this external movie, I want to unload it and tell the main timeline to move back to a labeled frame called, "First."
In the external swf, I have this code:
function handleMenu_Btn(evt:MouseEvent):void
{
stage.removeChild(this);
}
It actually unloads the external swf. The event listener in the main timeline movie "hears" the external swf get unloaded and fires the function that moves the main timeline to "First" just like it is supposed to do. But if I click a button to load the same movie and try to unload it a second time, I get this error:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at CourseMain/handleMenu_Btn()
I have read every post I can find here and in Google. None of the code suggested in these posts works. That tells me I am approaching this whole thing incorrectly.
Any suggestions? And by "suggestions" I mean examples of code. I am a newbie to AS3. Thank you for your kindness.
var thisMovieClip:MovieClip;
var myHBIMovieLoader:Loader = new Loader();
myHBIMovieLoader.load(new URLRequest("CBTs/HBI/CourseMain.swf"));
myHBIMovieLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, myHBIMovieLoaded);
function myHBIMovieLoaded(event:Event):void
{
thisMovieClip = MovieClip(myHBIMovieLoader.content);
stage.addChild(thisMovieClip);
thisMovieClip.addEventListener(Event.REMOVED_FROM_STAGE, removed)
function removed(event:Event):void
{
gotoAndStop("First");
}
}
gotoAndStop("CLCBlank");
As you can see on the last line of code, the main timeline moves to a labeled frame called, "CLCBlank." You can also see there is an event listener waiting for the external swf to be unloaded. It actually works, too, ONCE.
When I am done with this external movie, I want to unload it and tell the main timeline to move back to a labeled frame called, "First."
In the external swf, I have this code:
function handleMenu_Btn(evt:MouseEvent):void
{
stage.removeChild(this);
}
It actually unloads the external swf. The event listener in the main timeline movie "hears" the external swf get unloaded and fires the function that moves the main timeline to "First" just like it is supposed to do. But if I click a button to load the same movie and try to unload it a second time, I get this error:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at CourseMain/handleMenu_Btn()
I have read every post I can find here and in Google. None of the code suggested in these posts works. That tells me I am approaching this whole thing incorrectly.
Any suggestions? And by "suggestions" I mean examples of code. I am a newbie to AS3. Thank you for your kindness.