Flash uses several techniques to measure the passage of time in projects. The following are the most common strategies:
After you understand these elements, you'll be able to make your projects do the following:
There's also a special ActionScript tool setInterval() that allows a function to be called at a regular specified interval (measured in milliseconds). Consider the following example: function rotateClip() { myMovieClip_mc._rotation += 10; } setInterval(rotateClip, 1500); The first three lines of the script define the function that will be used. Next, the setInterval() action is set up to call the rotateClip() function every 1.5 seconds (1,000 milliseconds equals 1 second). If you want to pass arguments to the called function, simply add them to the setInterval() action: setInterval (updateMessageFunction, 20000, "Hello", arg2, arg3) A setInterval() action can be turned on and off by assigning a variable name, as in the following example: var myInterval:Object = setInterval(rotateClip, 1500); This example assigns the name myInterval to the setInterval() action. To remove the functionality of the setInterval() action, use the following syntax: clearInterval(myInterval); Using the syntax shown, you can initiate the setInterval() action at any time, calling any function. |