flash鼠标事件

stage.addEventListener(MouseEvent.CLICK,MouseEventHandle1);
function  MouseEventHandle1 (e:MouseEvent):void {
trace("这是一个鼠标单击的处理");
}

stage.doubleClickEnabled=true;//MouseEvent.DOUBLECLICK事件生效。
stage.addEventListener(MouseEvent.DOUBLE_CLICK,MouseEventHandle2);
function  MouseEventHandle2 (e:MouseEvent):void {
trace("这是一个双击处理");
}

stage.addEventListener(MouseEvent.MOUSE_DOWN,MouseEventHandle3);
function  MouseEventHandle3 (e:MouseEvent):void {
trace("这是一个鼠标按下处理");
}

stage.addEventListener(MouseEvent.MOUSE_MOVE,MouseEventHandle4);
function  MouseEventHandle4 (e:MouseEvent):void {
trace("这是一个鼠标移到场景上的处理");
}

stage.addEventListener(MouseEvent.MOUSE_OUT,MouseEventHandle5);
function  MouseEventHandle5 (e:MouseEvent):void {
trace("鼠标指针移出显示对象时触发事件");
}

stage.addEventListener(MouseEvent.MOUSE_OVER,MouseEventHandle6);
function  MouseEventHandle6 (e:MouseEvent):void {
trace("这是一个鼠标悬停的处理");
}

stage.addEventListener(MouseEvent.MOUSE_UP,MouseEventHandle7);
function  MouseEventHandle7 (e:MouseEvent):void {
trace("这是一个鼠标按下松开后的处理");
}

stage.addEventListener(MouseEvent.MOUSE_WHEEL,MouseEventHandle8);
function  MouseEventHandle8 (e:MouseEvent):void {
trace("这是一个鼠标滚轮的处理");
}

stage.addEventListener(MouseEvent.ROLL_OUT,MouseEventHandle9);
function  MouseEventHandle9 (e:MouseEvent):void {
trace("这是一个鼠标铺开的处理");
}

stage.addEventListener(MouseEvent.ROLL_OVER,MouseEventHandle10);
function  MouseEventHandle10 (e:MouseEvent):void {
trace("这是一个鼠标翻转的处理");
}
//区别Flash as3中的mouse_over和roll_over,mouse_out,roll_out
//需要在场景中定义一个影片剪辑,在影片剪辑内定义一个按钮
Canvas.addEventListener(MouseEvent.ROLL_OVER,rollover);
Canvas.addEventListener(MouseEvent.ROLL_OUT,rollout);
Canvas.addEventListener(MouseEvent.MOUSE_OVER,mouseover);
Canvas.addEventListener(MouseEvent.MOUSE_OUT,mouseout);

 function rollover(event:MouseEvent):void{
trace("roll over");
}
 function rollout(event:MouseEvent):void{
trace("roll out");
}
 function mouseover(event:MouseEvent):void{
trace("mouse over");
}
 function mouseout(event:MouseEvent):void{
trace("mouse out");
}
//移入Canvas:roll over
//移入Canvas:mouse over

//移入Canvas中的按钮:mouse out
//移入Canvas中的按钮:mouse over

//再次移入Canvas:mouse out
//再次移入Canvas:mouse over

//移出Canvas:mouse out
//移出Canvas:roll out 

你可能感兴趣的:(AS3)