Link to home
Start Free TrialLog in
Avatar of katyjack
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.contentLoaderInfo.addEventListener(Event.COMPLETE, 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!
ASKER CERTIFIED SOLUTION
Avatar of Antonio Estrada
Antonio Estrada
Flag of Mexico image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Did this work for you?

-V