ArgumentError

i am trying to add a movieClip from the Library at run time.i created a clip named ‘smoke’ i linked it . its class name is ‘Smoke’. i want to add it to a clip named ‘monster’ when i click on the ‘monster’ clip. so inside the ‘monster’ clip i have the next code:

function killMonster(event:MouseEvent):void
{
	smoke=new Smoke();
	this.parent.addChild(smoke);
	smoke.x = this.x;
	smoke.y = this.y;
	this.parent.removeChild(this);
}

but i keep getting this:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at Smoke/frame11()
i am not sure who the caller is and how to reach it?

You’re best to avoid placing code inside clips, instead create any methods for a class within the class definition code.

if you do place code inside a clip, fire an event instead of trying to execute things that are outside of the clip. then listen for the event from the parent and perform all appropriate actions at that level