• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 8. Loop Statements > An Alternative to Timeline Loops:setInterval( )

8.8. An Alternative to Timeline Loops:setInterval( )

As of Flash Player 6, we can use setInterval( ) to execute a function every n milliseconds. For example, the following code creates a function, moveBall( ), that moves the ball_mc movie clip 10 pixels to the right, and then uses setInterval( ) to execute that function every 20 milliseconds.

moveBall = function ( ) {
  _root.ball_mc._x += 10;
}
ballMoverID = setInterval(moveBall, 20);


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint