The
function is called every time the mouse is moved and
the new position of the cursor reset. However the
screen is only refreshed every time flash enters a new
frame (by default).This means
if the position changes quickly screen takes a lag
time to catch up as flash re-renders the stage and
displays the object in its new position.
By adding
the updateAfterEvent() function we can force flash to
re-render the stage each time the code is run.as the code
is triggered to by the mouse movement. the faster the
mouse moves the more frequently the stage is
re-rendered. Giving us a dynamic and proportional
control over the amount of re-rendering
The problem is that udateAfterEvent()
only works with certain clip events (mouseMove, mouseDown,
MouseUp, keyDown, keyUp.) to call it for as part
of ANY function we must use the setInterval() function.
The setInterval() function simply sets the time interval
between successive calls of a function. in this case
calling the function every 250 milliseconds. interval
= 250 set interval (this, "updateAfterEvent",
interval) The code here forces the flash player to
render the movieclip on the stage (main time line)
every 250 milliseconds calling the updateAfterEvent()
function directly. OR
you can put updateAfterEvent inside another function
and call that function using the setInterval() function.
for example
updateAfterEvent is inside the our function "randomNumber()"
.The
setInterval function is then set to activate the
random number generator and updatreafterEvent every
150 milliseconds.
More Examples
2d actionscript animation