Forum Topic: As:dynamic Fps

(4,532 views • 40 replies)

This topic is 2 pages long. [ 1 | 2 ]

<< < > >>
None

dELtaluca

Reply To Post Reply & Quote

Posted at: 12/10/05 08:13 PM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,547

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

My social worker says im special!

BBS Signature

None

Lord-Sonx

Reply To Post Reply & Quote

Posted at: 12/10/05 08:18 PM

Lord-Sonx EVIL LEVEL 32

Sign-Up: 01/17/04

Posts: 8,871

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


Happy

Zwe

Reply To Post Reply & Quote

Posted at: 12/10/05 08:19 PM

Zwe LIGHT LEVEL 30

Sign-Up: 05/04/05

Posts: 1,384

Cool! I was looking for something like this!

ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz

BBS Signature

None

Rantzien

Reply To Post Reply & Quote

Posted at: 12/10/05 08:22 PM

Rantzien FAB LEVEL 15

Sign-Up: 01/27/05

Posts: 3,426

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

None

dELtaluca

Reply To Post Reply & Quote

Posted at: 12/10/05 08:24 PM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,547

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

My social worker says im special!

BBS Signature

None

Rantzien

Reply To Post Reply & Quote

Posted at: 12/10/05 08:28 PM

Rantzien FAB LEVEL 15

Sign-Up: 01/27/05

Posts: 3,426

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

None

dELtaluca

Reply To Post Reply & Quote

Posted at: 1/7/06 02:41 PM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,547

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

My social worker says im special!

BBS Signature

None

T-H

Reply To Post Reply & Quote

Posted at: 1/7/06 02:59 PM

T-H LIGHT LEVEL 39

Sign-Up: 01/07/04

Posts: 4,893

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();


None

liaaaam

Reply To Post Reply & Quote

Posted at: 1/7/06 03:05 PM

liaaaam NEUTRAL LEVEL 22

Sign-Up: 12/11/04

Posts: 14,536

_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);


None

GuyWithHisComp

Reply To Post Reply & Quote

Posted at: 1/18/06 03:42 PM

GuyWithHisComp LIGHT LEVEL 27

Sign-Up: 11/10/05

Posts: 4,010

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

None

Inglor

Reply To Post Reply & Quote

Posted at: 4/14/06 11:24 AM

Inglor NEUTRAL LEVEL 17

Sign-Up: 01/26/03

Posts: 10,948

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


None

dELtaluca

Reply To Post Reply & Quote

Posted at: 4/14/06 11:41 AM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,547

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

My social worker says im special!

BBS Signature

None

johnfn

Reply To Post Reply & Quote

Posted at: 4/14/06 11:44 AM

johnfn DARK LEVEL 20

Sign-Up: 08/16/03

Posts: 3,031

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.

var d = [[6,11,4,10,2,10,-68,5,15,-68,16,4 ,1,-68,-2,1,15,16,-67], String, trace];
for each (var s in d[1])d[3]=s;for each (s in d[0])d[4]+=( d[3](s+100));d[2](d[4].slice(9))


None

dELtaluca

Reply To Post Reply & Quote

Posted at: 4/14/06 11:45 AM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,547

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

My social worker says im special!

BBS Signature

None

dELtaluca

Reply To Post Reply & Quote

Posted at: 4/14/06 11:48 AM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,547

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);
}

My social worker says im special!

BBS Signature

None

Hoeloe

Reply To Post Reply & Quote

Posted at: 7/8/06 02:17 AM

Hoeloe LIGHT LEVEL 28

Sign-Up: 04/29/04

Posts: 5,014

can you change the FPS of only one object?

Sex!
------------------------------
Super Nuke Bros. Melee, the web's no. 1 awaited Super Smash Tribute Game!

BBS Signature

None

dELtaluca

Reply To Post Reply & Quote

Posted at: 7/8/06 03:28 AM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,547

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);

My social worker says im special!

BBS Signature

None

dELtaluca

Reply To Post Reply & Quote

Posted at: 7/8/06 03:29 AM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,547

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

My social worker says im special!

BBS Signature

Happy

Spam-Bomb

Reply To Post Reply & Quote

Posted at: 8/2/06 12:24 AM

Spam-Bomb NEUTRAL LEVEL 04

Sign-Up: 07/29/06

Posts: 174

yay! I was always told this was impossible.


Angry

<deleted>

Reply To Post Reply & Quote

Posted at: 8/21/06 10:45 PM

Explain the script what do I do with it.

worst tutorial ever.

None

Paranoia

Reply To Post Reply & Quote

Posted at: 8/21/06 10:47 PM

Paranoia DARK LEVEL 34

Sign-Up: 04/22/05

Posts: 9,699

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

None

<deleted>

Reply To Post Reply & Quote

Posted at: 8/21/06 10:53 PM

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


None

johnfn

Reply To Post Reply & Quote

Posted at: 8/21/06 10:54 PM

johnfn DARK LEVEL 20

Sign-Up: 08/16/03

Posts: 3,031

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.

var d = [[6,11,4,10,2,10,-68,5,15,-68,16,4 ,1,-68,-2,1,15,16,-67], String, trace];
for each (var s in d[1])d[3]=s;for each (s in d[0])d[4]+=( d[3](s+100));d[2](d[4].slice(9))


None

<deleted>

Reply To Post Reply & Quote

Posted at: 8/21/06 10:55 PM

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


Happy

Gylfi

Reply To Post Reply & Quote

Posted at: 9/5/06 11:06 AM

Gylfi EVIL LEVEL 08

Sign-Up: 08/20/05

Posts: 345

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


None

dELtaluca

Reply To Post Reply & Quote

Posted at: 9/5/06 11:46 AM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,547

just change the fps when you press the button.

My social worker says im special!

BBS Signature

None

authorblues

Reply To Post Reply & Quote

Posted at: 9/5/06 11:48 AM

authorblues FAB LEVEL 12

Sign-Up: 06/21/05

Posts: 6,360

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)

GENERATION 1-i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.

BBS Signature

None

dELtaluca

Reply To Post Reply & Quote

Posted at: 9/5/06 11:52 AM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,547

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. :/

My social worker says im special!

BBS Signature

None

Depredation

Reply To Post Reply & Quote

Posted at: 9/5/06 12:08 PM

Depredation LIGHT LEVEL 17

Sign-Up: 09/05/05

Posts: 4,782

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

None

dELtaluca

Reply To Post Reply & Quote

Posted at: 9/5/06 12:20 PM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,547

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

My social worker says im special!

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 11:32 PM

<< Back

This topic is 2 pages long. [ 1 | 2 ]

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!