IEventDispatcher背後的邏輯是什麼?關於IEventDispatcher的問題
這是我見過的代碼:
var elements : Array = new Array();
var elements2 : Array = new Array();
for (var i:int = 1; i <= 5; i++) {
elements[i] = this['obj' + i];
elements2[i] = this['tracking' + i];
}
for each(var element_1 : IEventDispatcher in elements){
element_1.addEventListener(MouseEvent.MOUSE_OVER, moveUp);
}
for each(var element_2 : IEventDispatcher in elements2){
element_2.addEventListener(MouseEvent.MOUSE_OUT, moveDown);
}
function moveUp(e:MouseEvent):void{
e.currentTarget.y -= 30;
}
function moveDown(e:MouseEvent):void{
elements[elements2.indexOf(e.currentTarget)].y += 30;
}
@布賴恩威利斯謝謝。 – Marty 2011-05-20 05:27:18