Conflict between two loaded swf’s
I am having a conflict between two loaded swf files. When I load my external swf file into my main movie
I get an error because I used addChild/removeChild method in my external files as well as my main movie and it seems to conflict.
My main movie only uses the addChild method as each Child knocks the previous placed file out. If I get rid of the removeChild() in my external swf everything is ok and no error #2025.
How can I get around this simple issue other than removing the code in my external file. Forgive my ignorance if this is a simple fix. Any help would be greatly appreciated.
[COLOR=Black]MY ERROR[/COLOR]
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.at flash.display.DisplayObjectContainer/removeChild()
at brochure1_fla::MainTimeline/finished()
It seems like the removeChild() method in my external swf file
has a communication issue with my loader objects in my main movie which all use the addChild() method.
**
Code below is swf file I load into my main movie**
stop();
var preLoad:preloader=new preloader();
addChild(preLoad);
preLoad.x=150;
preLoad.y=150;
root.loaderInfo.addEventListener(ProgressEvent.PRO GRESS, progressHandler);
function progressHandler(myeventrogressEvent):void {
var myprogress:Number=myevent.target.bytesLoaded/myevent.target.bytesTotal;
preLoad.bar_mc.scaleX=myprogress;
preLoad.myTextField_txt.text=Math.round(myprogress *100)+"%";
}
root.loaderInfo.addEventListener(Event.COMPLETE, finished);
function finished(myevent:Event):void {
removeChild(preLoad);
play();
}
Below is the code from my main movie.
I get the error in my main movie
var myRequest22:URLRequest = new URLRequest(“brochure1.swf”);
menu_mc.brochure_btn.addEventListener(MouseEvent.M OUSE_UP, loadb22);
function loadb22(event:MouseEvent):void {
myloader.load(myRequest22);
stage.addChild(myloader);
myloader.x=300;
myloader.y=145;
myloader.scaleX=1;
myloader.scaleY=1;
}
var myRequest23:URLRequest = new URLRequest(“brochure2.swf”);
menu_mc.brochure2_btn.addEventListener(MouseEvent. MOUSE_UP, loadb23);
function loadb23(event:MouseEvent):void {
myloader.load(myRequest23);
stage.addChild(myloader);
myloader.x=300;
myloader.y=145;
myloader.scaleX=1;
myloader.scaleY=1;
}
[URL=“http://www.kirupa.com/forum/editpost.php?do=editpost&p=2548445”]