Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the frame rate within the movie 1

Status
Not open for further replies.

Pete222

Programmer
Dec 29, 2002
85
GB
I have got a animation I have made but want to slow down some parts and speed up others, I was wondering wether its possible to change the frame rate with code during the animation?

Pete.
My site: clix.to/F
 
no way to change FPS on the fly , but there are ways to simulate that .

have a look at this download..gives a workaround using a timer movie clip





_______________________________________
You know you're old if you can remember when bacon, eggs and sunshine were good for you
 
It works for the sarmple animation but I can't get it to work on my animation, what code do I put onto the frame where I want it to slow down?

Pete.
My site: clix.to/F
 
using mx or 5 ?

might be easier if you posted the fla so i could see what you want

_______________________________________
You know you're old if you can remember when bacon, eggs and sunshine were good for you
 
ok i looked over the code and stipped it down to essentials

place in frame 1 of main timeline

pathToClip.ClipName.onEnterFrame = function(){
onenterframe()
}
setFPS = function(frameRate){

onEnterFrame = wasteTime;
this.frameTime = 1000/Math.max(5,Math.min(120,frameRate));
this.t0=getTimer();
this.t1=getTimer();
}

resetFPS = function(){
onEnterFrame = null;
// clean up unneeded variables
delete(t0);
delete(t1);
delete(frameTime);
}

wasteTime = function(){
do{
this.t1=getTimer();
}while(t1<t0+frameTime);
this.t0 = t1;
}

}



to alter the frame rate in your clip add on each keyframe where you want the speed to alter

_root.setFPS(5); //slow
_root.setFPS(20) //faster

the code still has lots of room for improvment and i hope i havent cut away anything essential.






_______________________________________
You know you're old if you can remember when bacon, eggs and sunshine were good for you
 
the code shows:

pathToClip.ClipName.onEnterFrame = function(){

Does that mean i have to have a MovieClip slow down, or is there a way it can slow down the movie.


Here is the .fla file:
I wanted the FPS to goto 10 on frame 20 of Scene 2

Pete.
My site: clix.to/F
 
Sorry, for the link to work you have to copy it into the address bar!

Pete.
My site: clix.to/F
 
ok, thaks for the help!

Pete.
My site: clix.to/F
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top