i am trying to remove an object itself that is added to a movieclip on the stage.
this is what i have at first:
[AS]
package {
import flash.display.*;
public class DocClass extends MovieClip {
private var _mc:MovieClip;
private var _otherSprite:MCfromLibrary;
public function DocClass() {
_mc = new MovieClip();
_otherMC = new MCfromLibrary();
_mc.addChild(_otherMC);
addChild(_mc);
_otherMC.removeMyself();
}
}
}
package {
import flash.display.*;
public class MCfromLibrary extends MovieClip {
public function MCfromLibrary() {
//constructor
}
public function removeMyself() {
parent.removeChild(this);
}
}
}
[/AS]
the MCfromLibrary is a class of a movieclip from the library.
when i try to call the MCfromLibrary::removeMyself(), i got an error of:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
how should i remove the object itself through itself?