我正在尝试在同一类中创建一个类的新实例,并在创建实例后尝试删除 MouseDown 侦听器。
package com.objects{
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class StickDragDrop extends NumButton {
public var duplicateObject:MovieClip;
public function StickDragDrop() {
init();
}
public function init() {
addEventListener(MouseEvent.MOUSE_DOWN,stick);
}
public function stick(e:MouseEvent) {
duplicateObject=new e.currentTarget.constructor
addChild(duplicateObject);
duplicateObject.startDrag();
duplicateObject.removeEventListener(MouseEvent.MOUSE_DOWN,stick);
duplicateObject.addEventListener(MouseEvent.MOUSE_DOWN,unStick);
}
public function unStick(e:MouseEvent) {
stopDrag();
}
}
}