somebody621
Member
|
Made a little code to test the FPS of an movie. My movies keep lagging. Here goes. Type this code on the first frame of an MC's timeline. It's heavily commented, so beware! The comments are there for a reason, and figure out what the code is doing before you copy and paste(I hate copy and pasters). //set the FPS. Movie only runs through this code once. It's just to set it
var FPS=1;
//set a variable i. This will be used to see how many times the getFPS function has run
var i=1;
//the movies framespeed that you set in the properties panel. You can change this around. All it's there for is to test the lag of the movie.
var j=24;
//on every frame
onEnterFrame=function(){
//make a variable FPS increase by one. If you have Flash 5 or lower, put FPS+=1.
FPS++
//see how how many frames have passed. Delete this code if you want.
trace(FPS);
}
//define a function that runs on a set interval, defined at the end. It requires no arguments or parameters
getFPS = setInterval (function(){
//the actual framespeed is the amount of frames passed divided by how many times this code has run, since it runs every second. FPS=frames per second.
actualFPS=FPS/i;
//test the lag of the movie. All this is is subracting the framespeed the movie is going from the framespeed the movie should be going.
actualLag=j-actualFPS;
//the framespeed rounded to the nearest whole number
approxFPS=Math.round(actualFPS);
approxLag=Math.round(actualLag);
/*make variable i increase. i represents the amount of times this code has run. You could also
delete the actualFPS = FPS/i line, and put FPS=1 right here, but that would be less accurate. Also, for
flash versions 5 and lower put i+=1.*/
i++
//run this code every second.
},1000);
//code made by somebody621
Make two dynamic textboxes, one with the variable name approxLag, and the other with the variable name approxFPS. You can change these to other variables in the code, but I don't like huge irrational numbers. Label them with static textboxes next to them. Ideas:You could turn this into a componant for other movies. Then you wouldn't have to dig inside the movie clip to set the variable j, just type into the component.
|