O'Reilly logo

Essential ActionScript 3.0 by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Post-Event Screen Updates

In the previous section, we learned that scheduled screen updates automatically occur at intervals governed by the frame rate. We also learned that visual changes made by event listeners are not rendered until the next scheduled screen-update time. At a typical frame rate of 24 frames per second, the delay between the execution of an event listener and the rendering of its visual output is typically imperceptible. However, for visual changes that are triggered by mouse and keyboard input, even slight delays can make an application feel jittery or sluggish. Accordingly, ActionScript gives every mouse and keyboard event listener function the special ability to trigger a post-event screen update. A post-event screen update is an update that occurs immediately following the dispatch of an event, ahead of the next scheduled update.

To request a post-event screen update in response to a mouse event, we invoke MouseEvent.updateAfterEvent( ) on the MouseEvent object passed to any mouse event listener function. For example, the following code triggers a post-event screen update in response to a MouseEvent.MOUSE_MOVE event:

private function mouseMoveListener (e:MouseEvent):void {
  e.updateAfterEvent();  // Trigger update
}

To request a post-event screen update in response to a keyboard event, we invoke KeyboardEvent.updateAfterEvent( ) on the KeyboardEvent object passed to any keyboard event listener function. For example, the following code triggers a post-event screen ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required