Is it possible to access the type of object being interacted with so I can create a new instance of the same object? So for example in the code below I have the movieclip myItem. After it's clicked it is removed from stage and then moved to the inventory. When I click on it there, is it possible to create a new instance of mcItemToDuplicate using the event information parameters? (while allowing myItem to be where it is).
My code looks something like this:
public function moveclip() {
var myItem:mcItemToDuplicate = new mcItemToDuplicate();
stage.addChild(myItem);
myItem.addEventListener(MouseEvent.CLICK, pickUp);
}
private function pickUp(e:MouseEvent){
stage.removeChild(MovieClip(e.target));
MovieClip(e.target).removeEventListener(MouseEvent.CLICK, pickUp);
inventory.addChild(MovieClip(e.target));
MovieClip(e.target).addEventListener(MouseEvent.CLICK, useItem);
}
private function useItem(e:MouseEvent){
//??
}