all groups > flash actionscript > september 2005 >
You're in the

flash actionscript

group:

Adjusting Movie Playback Speed


Adjusting Movie Playback Speed eugene_man
9/23/2005 9:14:22 PM
flash actionscript: I'd like to be able to adjust the playback speed of a movie in an .SWF file
using scripting. Perhaps by passing a speed multiplier or divider parameter to
the .SWF file via the FlashVars mechanism of the <object> or <embed> tags. Any
suggestions on how to do this?
Re: Adjusting Movie Playback Speed NSurveyor
9/23/2005 9:31:52 PM
You can't adjust the FPS, (well, if you load a movie that has a different frame
rate in _level0, the new frame rate is used BUT you lose everything in higher
levels). However, you can simulate it with setInterval and updateAfterEvent.
Put this code on Frame 1:

MovieClip.prototype.setFPS = function(fps) {
this.clearFPS();
this.stop();
var playIt = function(mc){
mc.nextFrame();
updateAfterEvent();
}
arguments.callee.id = setInterval(playIt, 1000/fps, this);
};

MovieClip.prototype.clearFPS = function() {
if (this.setFPS.id != undefined) {
clearInterval(this.setFPS.id);
delete this.setFPS.id;
}
};

Then, when you want to change (simulate) the fps, use:

MOVIECLIP_INSTANCE_GOES_HERE.setFPS(30); // sets the fps to 30

and when you want to stop:

MOVIECLIP_INSTANCE_GOES_HERE.clearFPS(); // clears the fps

When you clear the fps, the movie will be stopped, so use play() if you want
to continue playing at normal playback speed..
Re: Adjusting Movie Playback Speed Joshua Hansen
9/23/2005 9:34:39 PM
Don't think you can with frame animation, but if it's scripted via an
onEnterFrame event handler you can slow it like so:

var frameCounter:Number = 0;
var frameDivider:Number = 2;

mc.onEnterFrame = function() {
if(frameCounter++ == frameDivider) {
// Do animation
mc.doSomething();

// Reset
frameCounter = 0;
}
};

Hope this helps.



[quoted text, click to view]

AddThis Social Bookmark Button