00:00
00:00

As:dynamic Fps

8,080 Views | 40 Replies
New Topic Respond to this Topic

As:dynamic Fps 2005-12-10 20:13:57


a very simply approach to having a dynamic FPS, ie an fps you can change with AS is making your own frame buffer: here is a sample

http://img235.images..age=untitled28wh.swf

the basis of the frame buffer are

function main():Void
{
//code
}
var inter:Number = setInterval(main,1000/fps);

where you replace fps with youre desired fps

basicly, for this to work, you have to replace youre onEnterFrames with this function, to stop slow down, its best to use only the ONE main() function to handle all clips (you could make this easier for yourself by each movieclip having an 'hahaloop' function that is called by the main() function

if you want to change the fps:

clearInterval(inter);
inter = setInterval(main,1000/newfps);

simple, but effective


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature

Response to As:dynamic Fps 2005-12-10 20:18:27


thats rather cool!
although rather pointless for most types of flash.. although a game that gets faster over time woudl suit this... hmm...

Response to As:dynamic Fps 2005-12-10 20:19:35


Cool! I was looking for something like this!


ABCDEFGHIJKLMNOPQRSTUVWXYZ

abcdefghijklmnopqrstuvwxyz

BBS Signature

Response to As:dynamic Fps 2005-12-10 20:22:32


It's so little code that it barely needs explanation, but still:

AS: Functions - Basic by Inglor
AS: Intervals by Inglor

Anyway, yeah it's the best way to "change fps". Good


BBS Signature

Response to As:dynamic Fps 2005-12-10 20:24:28


At 12/10/05 08:22 PM, Santazien wrote: It's so little code that it barely needs explanation, but still:

lol compare it to my other threads, its a relief for me that it is so little code, but its not something alot of people might think of so easily and its something i was explaining to dizimz so i just decided to post it here too


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature

Response to As:dynamic Fps 2005-12-10 20:28:49


At 12/10/05 08:24 PM, -dELta- wrote: lol compare it to my other threads, its a relief for me that it is so little code, but its not something alot of people might think of so easily and its something i was explaining to dizimz so i just decided to post it here too

Yeah, I know, little code doesn't mean there's a problem =)
I'm not complaining ;)


BBS Signature

Response to As:dynamic Fps 2006-01-07 14:41:08


someone was asking about changing fps of the movie for an animation:

applying this code, instead of having the movie play normally, add a stop to the first frame of animation, then in the function, just add nextFrame(); so that everytime the function loops it moves the playahead one frame


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature

Response to As:dynamic Fps 2006-01-07 14:59:19


Here's the code I have posted a few times in response to animation dynamic fps questions:

stop();
ratte = ( 1000 / fps )
newRate = setInterval(function(){
_root.nextFrame();
}, ratte);

Put your new framerate where it says "fps"

when you want to go back to the regular rate, use:

clearInterval(newRate);
play();

Response to As:dynamic Fps 2006-01-07 15:05:41


_global.changeFPS = function(fps:Number):Void {
if (fps != 24) {
_root.stop();
_root.ratte = (1000/fps);
_root.newRate = setInterval(function () {
_root.nextFrame();
}, _root.ratte);
} else {
clearInterval(_root.newRate);
}
};

Change 24 for your actual framerate, to change the framerate just do:

changeFPS(1337);

And to go back to the actual framerate:

changeFPS(24);


Sup, bitches :)

BBS Signature

Response to As:dynamic Fps 2006-01-18 15:42:20


And to really make it look good and not laggy even if 30 fps (like in the example) you should have 100 fps at start and instead change directly with code to the starting fps..


BBS Signature

Response to As:dynamic Fps 2006-04-14 11:24:15


this only effects the main timeline, throw in a recursive for... in loop

Response to As:dynamic Fps 2006-04-14 11:41:01


At 4/14/06 11:24 AM, Inglor wrote: this only effects the main timeline, throw in a recursive for... in loop

function loop(a:MovieClip,f:Function)
{
for(var b:String in a)
{
if(a[b] instanceof MovieClip) loop(a[b],f);
}
f(a);
}

function stopit(a:MovieClip):Void
{ a.stop();}

onMouseDown = function()
{
loop(_root,stopit);
}
{ a.stop(); }

loop(_root,stopit);

in this case, it would stop all movieclips


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature

Response to As:dynamic Fps 2006-04-14 11:44:01


I know this is an old topic but...

I think when you're actually changing the FPS you should set it a little higher then what you actually want, since there is a little bit of lag. Either that or it's my webbrowser.


Come join music competitions on Chips Compo and hang on our Discord!

Good artists copy. Great artists get banned from the Audio Portal.

BBS Signature

Response to As:dynamic Fps 2006-04-14 11:45:38


i messed that up a teensy bit, the last call of loop shouldnt be there, and also this can be used to call a function on every movieclip in a given hierarchy


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature

Response to As:dynamic Fps 2006-04-14 11:48:48


or not, i messed it up more than that...... BLAH

function loop(a:MovieClip,f:Function)
{
for(var b:String in a)
{
if(a[b] instanceof MovieClip) loop(a[b],f);
}
f(a);
}

function stopit(a:MovieClip):Void
{ a.stop();}

onMouseDown = function()
{
loop(_root,stopit);
}


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature

Response to As:dynamic Fps 2006-07-08 02:17:39


can you change the FPS of only one object?


BBS Signature

Response to As:dynamic Fps 2006-07-08 03:28:24


At 7/8/06 02:17 AM, Hoeloe wrote: can you change the FPS of only one object?

if you mean an animational object using nextFrame(); then not exactly, you can loop through every movieclip on the stage, and apply the FPS, however, the more movieclips, and the more nested, and sub nested movieclips you have, the slower it will run, but you could use a loop like this

function next_frame(m:MovieClip):Void
{
for (var it:String in m)
{
if (m[it] instanceof MovieClip)
{
next_frame(m[it]);
}
}
m.nextFrame();
}

then you can choose a certain tree of movieclips to increment the frame of, so for everything, you would do next_frame(_root);


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature

Response to As:dynamic Fps 2006-07-08 03:29:53


and ofcourse, with this, you could edit it to stop all movieclips, so that you can start to apply a dynamic fps


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature

Response to As:dynamic Fps 2006-08-02 00:24:52


yay! I was always told this was impossible.

Response to As:dynamic Fps 2006-08-21 22:45:22


Explain the script what do I do with it.

worst tutorial ever.

Response to As:dynamic Fps 2006-08-21 22:47:15


At 8/21/06 10:45 PM, Teh_Noobz_Killa wrote: Explain the script what do I do with it.

It's already been explained here, and people with a decent understanding of AS shouldn't have too much difficulty grasping the concepts presented.

worst tutorial ever.

Your mom's the worst tutorial ever.

never, ever insult delta

BBS Signature

Response to As:dynamic Fps 2006-08-21 22:53:06


Just give me the code. Idk I have a major head ache form doing AS and I can't understand much right now.

Response to As:dynamic Fps 2006-08-21 22:54:41


At 8/21/06 10:53 PM, Teh_Noobz_Killa wrote: Just give me the code.

I don't get it. The code is on the first post.


Come join music competitions on Chips Compo and hang on our Discord!

Good artists copy. Great artists get banned from the Audio Portal.

BBS Signature

Response to As:dynamic Fps 2006-08-21 22:55:23


It didn't work. Where do I put it?

Response to As:dynamic Fps 2006-09-05 11:06:25


Does anyone know how this can be applied for buttons? A slow down button?

Response to As:dynamic Fps 2006-09-05 11:46:23


just change the fps when you press the button.


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature

Response to As:dynamic Fps 2006-09-05 11:48:25


At 8/21/06 10:47 PM, _Paranoia_ wrote:
never, ever insult delta

why not? i do it all the time...
(like the fact that he has like a 3 inch penis)


BBS Signature

Response to As:dynamic Fps 2006-09-05 11:52:48


At 9/5/06 11:48 AM, authorblues wrote: (like the fact that he has like a 3 inch penis)

usually i wouldnt mind about these sort of comments that have kind of become normal throughout our little community, but you cant post incorrect facts, you have to atleast get it correct. :/


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature

Response to As:dynamic Fps 2006-09-05 12:08:00


At 9/5/06 11:52 AM, -dELta- wrote: usually i wouldnt mind about these sort of comments that have kind of become normal throughout our little community, but you cant post incorrect facts, you have to atleast get it correct. :/

Lol, owned :).Nice tut dElta, seems quite simple now. I remeber reading it when i was a newbie. Now i understand it perfectly :D.

Hows the componenets part going?

BBS Signature

Response to As:dynamic Fps 2006-09-05 12:20:48


At 9/5/06 12:08 PM, Depredation wrote:
Hows the componenets part going?

sshhhh, i got coursework to do :p once there is a deadline, ill be sure to fit it in, till then, i wont be able to properly concentrate on it


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature