ActionScript 3 actionscript 3 - 按钮动作[听多个事件。例如。 MOUSE_OVER,MOUSE_OUT,MOUSE_UP]

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 actionscript 3 - 按钮动作[听多个事件。例如。 MOUSE_OVER,MOUSE_OUT,MOUSE_UP]相关的知识,希望对你有一定的参考价值。

// add event listeners to listen for button events [mouse over, mouse out, mouse up] 
// and then - when one happens - trigger the function called 'buttonstuff'
this.stupidbutton.addEventListener(MouseEvent.MOUSE_OVER, buttonstuff);
this.stupidbutton.addEventListener(MouseEvent.MOUSE_OUT, buttonstuff);
this.stupidbutton.addEventListener(MouseEvent.MOUSE_UP, buttonstuff);
// end event listeners


// buttonstuff function - triggered by the above listeners
function buttonstuff(event:MouseEvent):void
{
	// switch to 'switch' what the function does, depending 
	//on which mouse event the button listener has picked up. 
	//think of it as standing for "in case of this - do this"
	switch(event.type)
	{
		
	// in 'case' the listener detected a mouse over
	case MouseEvent.MOUSE_OVER:
	
	// replace the trace with your own button actions
	trace("button rolled over");
	
	// each case always ends with a 'break'
	break;
	// end in 'case' the listener detected a mouse over
	
	// in 'case' the listener detected a mouse out
	case MouseEvent.MOUSE_OUT:
	
	// replace the trace with your own button actions
	trace("button rolled off");
	
	// each case always ends with a 'break'
	break;
	// end in 'case' the listener detected a mouse out
	
	// in 'case' the listener detected a mouse up
	case MouseEvent.MOUSE_UP:
	
	// replace the trace with your own button actions
	trace("button released");
	
	// each case always ends with a 'break'
	break;
	// end in 'case' the listener detected a mouse up
	
	}
	// end switch to 'switch' what the function does, depending on 
	//which mouse event the button listener has picked up
	
}
// end buttonstuff function

以上是关于ActionScript 3 actionscript 3 - 按钮动作[听多个事件。例如。 MOUSE_OVER,MOUSE_OUT,MOUSE_UP]的主要内容,如果未能解决你的问题,请参考以下文章

在 JavaScript 和 ActionScript 之间共享数组引用

MXML 和用于移动设备的 ActionScript 之间的真正区别是啥?

ActionScript 3 使用ActionScript 3暂停框架

ActionScript 3 ActionScript 3延迟功能

ActionScript 3 ActionScript 3 SliceBitmap类

ActionScript 3 ActionScript 3中的XML循环