HomeAfter Sale Support Working with Flash Advanced How to change the speed in flash

How to change the speed in flash


Q: How can I speed the frame rate or slow it down when the movie is playing? For example, I would like to slow the frame rate from the default of 20 fps to 15 fps from frame #80 to frame #150. Then frame rate should speed back up to 20 fps after frame #151, (fps = frames per second).

A: One way is to use "interval". An example of changing the speed of the movie from frame #80 to frame #150 is shown below.
Create a key frame at frame #80 and place this script:


  
var fps:Number = 80;
var intervalID:Number = setInterval(this, "advanceFrame", 1000/fps);
stop();
//
function advanceFrame() {
   clearInterval(intervalID);
   gotoAndStop(_currentframe+1);
   if (_currentframe<151) {
       intervalID = setInterval(this, "advanceFrame", 1000/fps);
   } else {
       play();
   }
}