Action SCRIPT 2.0 之  MouseEvent 參考

stop();

stage.addEventListener(MouseEvent.MOUSE_MOVE,stageEvent);
stage.addEventListener(Event.MOUSE_LEAVE,stageLeave);

mcCircle.addEventListener(MouseEvent.MOUSE_OVER,addEvent);
mcCircle.addEventListener(MouseEvent.MOUSE_OUT,addEvent);
mcCircle.addEventListener(MouseEvent.MOUSE_DOWN,addEvent);
mcCircle.addEventListener(MouseEvent.MOUSE_UP,addEvent);
mcCircle.addEventListener(MouseEvent.MOUSE_WHEEL,addEvent);

mcCircle2.addEventListener(MouseEvent.ROLL_OUT,workAround);
mcCircle2.addEventListener(MouseEvent.ROLL_OVER,workAround);
mcCircle2.addEventListener(MouseEvent.CLICK,workAround);
mcCircle2.doubleClickEnabled = true;
mcCircle2.mouseChildren = false;//because of nested MC's
mcCircle2.addEventListener(MouseEvent.DOUBLE_CLICK,workAround);

function addEvent(evt:MouseEvent) {
var fieldName = evt.target;
fieldName.text = evt.type;
}

function workAround(evt:MouseEvent) {
mcCircle2.txtEvent.text = evt.type;
}

function stageEvent(evt:MouseEvent) {
txtEvent.text = evt.type+"\n x:"+Math.floor(evt.stageX)+" y:"+Math.floor(evt.stageY);
}

function stageLeave(evt:Event) {
txtEvent.text = evt.type;
}

註: 可用 trace 去確認事件是否達成.


Frank 發表在 痞客邦 留言(0) 人氣()