简体   繁体   中英

AS3 Error When Trying To Remove a Movieclip from the Stage

I have an actual movieclip on the main timeline called "img_mc" which I want to remove when a certain frame is hit. So I placed the following code on that frame: removeChild(img_mc) - even though Flash removes it, I get the following error:

 ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()

I don't understand what I am missing here? I also tried

 this.removeChild(img_mc); and

 stage.removeChild(img_mc);

Thanks!

I created a function:

function stopTheScript() {
    if (img_mc.parent){
        img_mc.parent.removeChild(img_mc); 
    }
}

which seems to work- meaning I don't get an error - however I don't quite understand why? I thought any movieclip placed on the timeline is automatically a child?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM