0
我想在同一個類中創建一個類的新實例,並在創建實例後嘗試刪除MouseDown偵聽器。爲什麼對象的新實例上的removeEventListener不起作用?
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();
}
}
}
你能解釋一下更多關於你想要達到什麼嗎?首先,我不明白爲什麼要將重複對象添加到目標對象? – Art