katyjack
asked on
AS3: Removing child throws error
Here's what I'm trying to do:
1. Load swf
2. Add children movieclips to swf
3. click one of the children movieclips
4. unload swf and start all over again
However I keep getting the error "The supplied DisplayObject must be a child of the caller". Even when I simplify the code down to this:
function loadSwf(newSwf) {
swfLoader.load(new URLRequest(newSwf));
swfLoader.contentLoaderInf o.addEvent Listener(E vent.COMPL ETE, onSwfLoad);
function onSwfLoad(e:Event) {
curSwf = e.target.content;
stage.addChild(curSwf););
unloadSwf();
}
}
function unloadSwf() {
this.removeChild(curSwf);
}
I continue to get the error. What am I doing wrong? Argh!
1. Load swf
2. Add children movieclips to swf
3. click one of the children movieclips
4. unload swf and start all over again
However I keep getting the error "The supplied DisplayObject must be a child of the caller". Even when I simplify the code down to this:
function loadSwf(newSwf) {
swfLoader.load(new URLRequest(newSwf));
swfLoader.contentLoaderInf
function onSwfLoad(e:Event) {
curSwf = e.target.content;
stage.addChild(curSwf););
unloadSwf();
}
}
function unloadSwf() {
this.removeChild(curSwf);
}
I continue to get the error. What am I doing wrong? Argh!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
-V