So, i’m loading a swf into my main movie when an area in the main movie is clicked. It loads perfectly, and the close button works fine. The problem is that after it’s closed, if i try clicking to open it again, i get this error…
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::Loader/flash.display:Loader::_load()
at flash.display::Loader/load()
at ActiveInteractive_fla::MainTimeline/golfLoad()
Here’s my code…
//IMPORTS:::::::::::::::::::::
import caurina.transitions.*;
import flash.events.*;
import flash.display.MovieClip;
//LOADER FOR CONTENT:::::::::::::::
var myLoader:Loader = new Loader();
//GOLF BUTTON:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
golf_btn.addEventListener(MouseEvent.MOUSE_OVER, golfOver);
function golfOver(evt:MouseEvent):void {
Tweener.addTween(golf_highlight, {//scaleY:1,
alpha:.60,
time:.5,
delay:0,
transition:"easeOutSine"});
}
golf_btn.addEventListener(MouseEvent.CLICK, golfLoad);
function golfLoad(event: MouseEvent) {
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
myLoader.load(new URLRequest("golf_co.swf"));
stage.addChild(myLoader);
}
golf_btn.addEventListener(MouseEvent.MOUSE_OUT, golfOut);
function golfOut(evt:MouseEvent):void {
Tweener.addTween(golf_highlight, {//scaleY:1,
alpha:0,
time:.5,
delay:0,
transition:"easeOutSine"});
}
//FUNCTION FOR CLOSE BUTTON IN INDIVIDUAL LOADED SWF:::::::::::::::::::::::::::::::
var swf:MovieClip;
function onComplete(e:Event):void {
swf = e.target.content;
//trace("loaded movie is " + swf);
//trace("button instance in loaded movie is " + swf.close_btn);
addChild(swf);
var button:SimpleButton = swf.callout.close_btn;
button.addEventListener(MouseEvent.CLICK, closeSWF);
}
function closeSWF(e:Event):void {
Tweener.addTween(swf.callout,
{scaleX:0, scaleY:0, alpha:0, time:.5, transition:"easeOutSine"});
removeChild(swf);
}
Probably a simple fix, but i’m frizzity fried and can’t seem to locate it! Thanks for the extra set of eye balls!