Jump to content


controlling frames per second of individual animations

Recommended Posts

I'm currently working on a flash project that includes a rather large number of looping frame per frame sprite animations and while the main swf runs at 60fps most of the sprite animations need to run at a considerably lower framerate, some at 30, some at 12 some maybe even lower.

Because flash doesn't have a way to tweak the fps of individual animations (except adding each frame multiple times which I found to be cumbersome and with framereates that aren't divisible by 60 even impossible) I turned to TweenMax and TimelineMax and while I was at first dissapointed that the "ticker" property didn't exist (?) in the Flash version, I played around with it for a while and I thought I had discovered a solution that would make an animation with an arbitrary number of frames run at any framereate I wanted. I would add the frames into a movieclip with this code:

var fps:Number = 25
var finalduration:Number = ((1000/fps)*(totalF))/1000;
var totalF:Number = this.totalFrames;
var del:Number = finalduration/totalF;
var tween = new TweenMax(this, finalduration, {frame:totalF, repeat:-1, ease:Linear.easeNone});

the main trick was to define the duration by calculating the number of milliseconds one single frame needs to be visible multiply it by the number of frames in the animation and then by 1000 to get the value in seconds that tweenMax accepts, so that in the example above each frame would be visible for exactly 0,04 seconds resulting in a 25 fps animation.


...but for some reason this method doesn't seem to work. I noticed that there were several quirks in the resulting animation: The first frame would be skipped entierly, the second and third frame would be tweened about twice as fast as the rest of the animation, teh middle part would work fine and then the last frame would be cut short (it's displayed but not for as long as it should be)

I'm not exactly sure what's causing those problems... It was possible to get the tween to display the first frame by duplicating it but then the duration would of course be too long.

I'm currently testing out some other possible solutions I thought of (setting useFrames and caluclating the tame based on the 60fps, a timelineMax based method that defines a set delay between every single tweened frame...) but I kinda feel like my method should work and maybe I'm just overlooking something....

Link to comment
Share on other sites

This is a bit beyond the scope of what we typically provide in the forums, but maybe I can help a bit. I noticed you decleared totalF after you used it in another calculation above which I'd expect to throw an error. 


It'd be super helpful if you created a reduced test case FLA and posted it here (zip it first please). I'm not clear on exactly what you're trying to tween or how. Are you saying that you may have something like 1000 frames but you want the tween to not show them all, like skip several at a time (1, 5, 10, 15, etc.)? Or are you wanting to show them all but just slow it down? Are you aware there's a FramePlugin for MovieClips? 


An idea that may not help at all (again, I'm not sure what you're doing yet): create a paused tween that controls the frames with roundProps so that it only increments whole values, then use another tween to literally tween the time (or progress) of that tween. Again, that may not help at all. Just tossing ideas out. 

Link to comment
Share on other sites

Are you saying that you may have something like 1000 frames but you want the tween to not show them all, like skip several at a time (1, 5, 10, 15, etc.)? Or are you wanting to show them all but just slow it down? Are you aware there's a FramePlugin for MovieClips? 

I don't want any frames to be skipped, the seond question is basically correct. I want to slow the animation down so, so when an animation runs at 30 fps is should run at half speed compared to the rest of the 60fps animations, and basically it's about figuring out the correct duration for the different framerates.

I am using the frame plugin in the code (frame:totalF, so it tweens everything to the last frame of the animation).


I attached a fla with some example animations. The number animation should run at 5 fps and the two propellers at 30 while (hopefully) demonstrating the problem of the missing first frame I talked about earlier.

ex ample.zip

Link to comment
Share on other sites

you might find that SteppedEase in conjuction with the FramePlugin allows you to give the illusion of different frame rates


import com.greensock.*;
import com.greensock.easing.*;


TweenMax.to(mc1, 5, {frame:10, ease:SteppedEase.config(9)});
TweenMax.to(mc2, 10, {frame:10, ease:SteppedEase.config(9)});
TweenMax.to(mc3, 20, {frame:10, ease:SteppedEase.config(9)});






Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.