I am using Flash CS4 AS3
I have two buttons that when clicked either add or remove the five items listed below onto my stage. The code for the add button works fine and adds the objects to the stage each time I press it. The remove button works fine the first time removing the objects without generating an error but after the first time I if I add the objects back onto the stage using the addon button and then press the addoff button I get the #2025 error indicated below.
I found some code on the internet that allows me to trace and display the parent of these objects on "stage" but even when I use the stage.removeChild() command Flash is still generating the error each subsequent time that I use my remove button. Can someone please tell me why this is happening and how to fix it. Note that the .swf works regardless of this error but the error is annoying and should be fixable. Thank you.
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at MethodInfo-112() error
//I am using these commands to define and add the five objects on stage.
var wheels:MovieClip = new totalwheel
var wheelflap:MovieClip = new flap
var wheelflap2:MovieClip = new flap2
var flapholder:MovieClip = new holder
var handy:MovieClip = new hand
//These are the commands I use to remove the above objects from the stage.
These work fine the first time around but generate the above error when used subsequent times