actionscript 3按钮操作[监听单个事件。例如,鼠标向上移动]

Posted

tags:

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

actionscript3 version of the basic button action. in actionscript3, button actions can no longer be attached to the buttons themselves or called from the main timeline. you need to put an 'addEventListener' in the timeline to 'listen' for interaction with the button and then call an appropriate function to deal with that action.

the button needs to have an instance name. in this case it is called 'stupidbutton'
  1. // add an event listener to listen for a button release [mouse up] and then
  2. // when it happens - trigger the function called 'buttonstuff'
  3. this.stupidbutton.addEventListener(MouseEvent.MOUSE_UP, buttonstuff);
  4.  
  5. // buttonstuff function - triggered by the above listener
  6. function buttonstuff(event:MouseEvent):void
  7. {
  8.  
  9. // replace the trace with your own button actions
  10. trace("button pressed");
  11.  
  12. }
  13. // end buttonstuff function

以上是关于actionscript 3按钮操作[监听单个事件。例如,鼠标向上移动]的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 创建一个匿名事件监听器并立即删除第一个事件

ActionScript 3 AS3:onAdded事件监听器

在 actionscript 3 中使用多个或仅一个事件监听器

转Android开发20——单个监听器监听多个按钮点击事件

(ActionScript 3.0)我的函数没有通过按钮事件更新全局变量

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