updateAfterEvent( ) Global Function | Flash 5 |
render the contents of the Stage between frames |
When a function executes between frames in the Flash Player, any visual changes to the screen are not displayed until the next frame is rendered. However, within the following functions, we can force a screen refresh manually by invoking updateAfterEvent( ):
A setInterval( ) callback
MovieClip.onMouseMove( )
MovieClip.onMouseDown( )
MovieClip.onMouseUp( )
MovieClip.onKeyDown( )
MovieClip.onKeyUp( )
Note, however, that updateAfterEvent( ) is not an arbitrary screen-refreshing tool; outside of setInterval( ) and the handlers in the previous list, it has no effect. In Flash 6, even the Mouse and Key objects' event handlers do not support updateAfterEvent( ); however, they are expected to support it in future versions of the Player.
The following script causes pointer_mc to follow the mouse pointer. It uses updateAfterEvent( ) to refresh the screen every time the pointer moves (which may be more often than the frame rate):
pointer_mc.onMouseMove = function () { this._x = _root._xmouse; this._y = _root._ymouse; updateAfterEvent(); }
"Refreshing the Screen with updateAfterEvent( )," in Chapter 10