我的目标是在事件上生成一个圆圈,并在发生拖动时MOUSE_WHEEL
移动所有MOUSE_DOWN
圆圈,如 和 检测到的MOUSE_UP
。我通过将每个Sprite
创建的元素添加到一个数组中来完成此操作,并在鼠标向上/向下时迭代它。注意:Node
只是Sprite
类型的扩展。
但是,由于某种原因,只有最近绘制Sprite
的数组被移动。任何想法为什么?
我的画布课:
public function Canvas() {
trace("Starting it");
const background:Sprite = new Sprite();
background.graphics.beginFill(0x00000000);
background.graphics.drawRect(0, 0, this.stage.stageWidth, this.stage.stageHeight);
background.graphics.endFill();
addChild(background);
background.addEventListener(MouseEvent.MOUSE_WHEEL, createNode);
background.addEventListener(MouseEvent.MOUSE_DOWN, startObjectMove);
background.addEventListener(MouseEvent.MOUSE_UP, endObjectMove);
mNodeList = new Array();
}
...
}
我的 startObjectMove 和 endObjectMove 方法:
public function startObjectMove(pEvent:MouseEvent) : void {
trace("Starting drag...");
trace("There are " + mNodeList.length + " in list");
for (var i:int = 0; i < mNodeList.length; i++) {
var node:Node;
node = Node(mNodeList[i]);
node.startMove(pEvent);
}
}
public function endObjectMove(pEvent:MouseEvent) : void {
trace("Ending drag...");
trace("There are " + mNodeList.length + " in list");
for (var i:int = 0; i < mNodeList.length; i++) {
var node:Node;
node = Node(mNodeList[i]);
node.endMove(pEvent);
}
}
endMove
and方法startMove
只是调用this.startDrag()
and 。this.endDrag()