I'm trying to learn AS3 and have a test AS3 file to try and learn how to load/unload external swf files into a container on CLICK of 3 different buttons I have. What does this Output error mean and how would I fix it? I don't understand what it means that it has to be a "child of the caller."
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at test01_loadEXT_swf_fla::MainTimeline/goToHome()
Here's the AS3 that I have:
Code:
var page_loader:Loader = new Loader();
contact_mc.addEventListener(MouseEvent.CLICK, Contact);
function Contact(Event:MouseEvent):void {
var request:URLRequest = new URLRequest("contact.swf");
page_loader.load(request);
addChild(page_loader);
removeChild(container_mc);
}
bio_mc.addEventListener(MouseEvent.CLICK, Bio);
function Bio(Event:MouseEvent):void {
var request:URLRequest = new URLRequest("bio.swf");
page_loader.load(request);
addChild(page_loader);
removeChild(container_mc);
}
home_mc.addEventListener(MouseEvent.CLICK, Home);
function Home(Event:MouseEvent):void {
var request:URLRequest = new URLRequest("home.swf");
page_loader.load(request);
addChild(page_loader);
removeChild(container_mc);
}