insert into your document class
var frameManager = new frameRateKeeper(24,this);
addChild(frameManager);
// where 24 is the frame rate you want, then insert the following code into a file called frameKeeper.as
package{
import flash.utils.Timer;
import flash.display.MovieClip;
import flash.display.Stage;
public class frameRateKeeper extends MovieClip{
var requestedFrameRate = 30;
var frameTracker = 0;
var currentFrameRate = 30;
var stageInstance;
var secondTimer:Timer = new Timer(1000);
public function frameRateKeeper(num,sI)
{
stageInstance = sI;
requestedFrameRate = num;
currentFrameRate = num;
this.addEventListener("enterFrame",function(){ frameTracker += 1;});
secondTimer.addEventListener("timer", adjustFrameRate);
secondTimer.start();
}
public function adjustFrameRate(ext)
{
var curRate = frameTracker;
if(curRate > requestedFrameRate)
{
currentFrameRate --;
stage.frameRate = currentFrameRate;
}
if((curRate < requestedFrameRate) && (currentFrameRate < 90))
{
currentFrameRate += requestedFrameRate - curRate;
stage.frameRate = currentFrameRate;
}
//trace("stage set: " + currentFrameRate);
//trace("actual: " + curRate);
frameTracker = 0;
//stageInstance.frameRateCounter.text = stage.frameRate;
}
}
}