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

Chapter 14. Extending ActionScript > Setting Scripts to Trigger on Schedule

Setting Scripts to Trigger on Schedule

All the wild stuff covered in this chapter should have you pretty excited. There’s just one more topic that fits here—even though it isn’t really an “extension” of Flash. The setInterval() command enables you to identify a function that is to be executed automatically, at whatever frequency you desire. Normally, your scripts have to wait until an event triggers them. It’s obvious that a script waiting for a mouse press may take a long time before it executes (especially if the user doesn’t click), but even events, such as enterFrame and mouseMove, or simply reaching script in a keyframe are all limited by either how fast the movie’s framerate is or how fast the user can move his mouse. That is, an enterFrame script that executes every 1/12 of a second might not be often enough. Conversely, if you only want a script to trigger every 4 seconds, it’s somewhat difficult to do inside an enterFrame script.

For all the reasons listed previously, setInterval() is a great new feature. It’s super easy to use. Here’s the form:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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