We have reduced support for legacy browsers.

What does this mean for me? You will always be able to play your favorite games on Kongregate. However, certain site features may suddenly stop working and leave you with a severely degraded experience.

What should I do? We strongly urge all our users to upgrade to modern browsers for a better experience and improved security.

Is it possible to change animation speed without decreasing FPS?

I have an animated movieClip, and I need to change animation speed, changing FPS is not an option. And having multiple keyframes with different animation speeds isn’t a solution too, because it is a bicycle and jumping to another frame will not be smooth, could anyone help with this?

> *Originally posted by **[DrYoshiyahu](/forums/4/topics/313736?page=1#posts-6619095):***
>
> If it’s the wheels you’re animating; You can always try not using an animation to rotate them, but using actionscript instead.
>
> `public function everyframe() {
> bike.wheel.rotation += bikeSpeed;
> }`
Unfortunately it’s not only wheels:/
> How about using a Timer, possibly with TimerEvent#updateAfterEvent if you want to animate it faster than the frame rate of the movie.
Sounds like a good idea, i will try this
`
(When timer completed)
timer.start();
Bicycler.nextFrame();
`
From here on I only need to change timer clock, what do you think about this?

IIRC timer animation is resource heavy and unreliable time-wise. Maybe you should use tweens within your MC and control them programmatically? (It’s likely that your goal will require recreation of that bicycle MC.)

> *Originally posted by **[vesperbot](/forums/4/topics/313736?page=1#posts-6619242):***
>
> IIRC timer animation is resource heavy and unreliable time-wise. Maybe you should use tweens within your MC and control them programmatically? (It’s likely that your goal will require recreation of that bicycle MC.)
Controlling tweens programmatically would be certainly better, but which functions should i use? Is there some information about this? (tried googling but didn’t find anything).

I looked at tween function, it’s good but won’t work with my case as it is only for moving, fading object. My movieclip is animated with different keyFrames (it’s a real animation) and i need to control the speed of how fast this movieClip goes through all it’s frames. BigJM’s suggestion will work, only 1 downside that it is resource hungry.

Thanks to Aaants, that’s a very nice class.
But I had to comment out
`
desiredFPS=mainTimelineFPS;
`
Because it would fix my desired fps to main timeline fps, wouldn’t it?
This step:
`
step+=desiredFPS/mainTimelineFPS;
`
Is definitely very smart.
But I can’t understand how these lines work:
`
if (step>=totalFrames+1) step-=totalFrames;
gotoAndStop(int(step));
`
For example if I had desiredFPS and mainTimelineFPS ratio of 2:1, and a movieClip with 160 frames.
It would add +2 to step, each frame, and when step is \> 161 it will minus 160, and step will be equal to 2, then movieClip goes to frame 2.
Now it will start raising step again from 2, but once it becomes greater than 161 step will be lowered by 160 again and it will be equal to 2 again, so how does it work? shouldn’t movieClip be standing still on frame 2?

There’s no need to comment it out – that line just sets a default that you can overwrite after you have made the MC:
` var myClip = new GuyOnBike(); // makes a bike with default FPS
// assumes GuyOnBike is a subclass of VaryingFPSMovieClip
myClip.desiredFPS = 15; // overwrites default FPS
`
You can even change the FPS on the fly; he could be at 15 FPS for a while then you just change it again to speed him up. Change it over time to make it look like he’s accelerating.
The other lines just make sure the MovieClip stays within a valid frame range. Normal MCs loop, I coded that part to make sure this one did too. It won’t stand still on frame 2 because it needs to step all the way back to 161+ before it is reset again.

> *Originally posted by **[Aaants](/forums/4/topics/313736?page=1#posts-6623038):***
>
> The other lines just make sure the MovieClip stays within a valid frame range. Normal MCs loop, I coded that part to make sure this one did too. It won’t stand still on frame 2 because it needs to step all the way back to 161+ before it is reset again.
Now I understand, I mistook
`
if (step>=totalFrames+1) step-=totalFrames;
gotoAndStop(int(step));
`
for:
`
if (step>=totalFrames+1)
{
step-=totalFrames;
gotoAndStop(int(step));
}
`
Thanks! it’s working very well.
I also looked at updateAfterEvent, but site says that this function only redraws a stage after MouseEvent, KeyboardEvent or TimerEvent. I don’t know if it’s possible to use this with animation which is incide a MovieClip, but it would be possible to use this if there is an object tweened with code, but this example works the same with updateAfterEvent or without it:/
`
function onTimer(event:TimerEvent):void {
if (40 < my_mc.x && my_mc.x < 375) {
my_mc.x-= 50;
} else {
my_mc.x=374;
}
//event.updateAfterEvent();
}
var moveTimer:Timer=new Timer(500,50);
moveTimer.addEventListener(TimerEvent.TIMER,onTimer);
moveTimer.start();
`