About

<#TEMPLATE_INCLUDE_NINEPAGE_ABOUTME#>
  • Oct

    11

    在 AS3 中当显示对象被分配鼠标事件时不再是全局的,比如拖动一个对象或画线时,如果鼠标指针移动的过快,并超出屏幕时,它是会意外中止的;再如当鼠标指针在显示对象外释放时无法侦听到 mouseUp 事件。

    对此,官方给出的建义是通过侦听 stage 的鼠标事件,就可以成为全局鼠标事件对象。如:

    stage.addEventListener(MouseEvent.MOUSE_MOVE, dragObject); 

    Fora global mouseMove event, assign listeners to the stage object. The stage object will always receive mouseMove events despite what other displayobjects the mouse is over (as long as the mouse moves within the Flash Player window). This way ifan object is being dragged,and the mouse moves off the object, the mouseMove event will still fire and the object will continue to follow the mouse.