Forum Topic: AS3: Changing Framerate

(1,454 views • 28 replies)

This topic is 1 page long.

<< < > >>
Happy

Siggles

Reply To Post Reply & Quote

Posted at: 5/4/07 06:44 PM

Siggles DARK LEVEL 17

Sign-Up: 04/07/06

Posts: 1,622

AS3: Main

Okay, so I made this before, but I screwed up, so here is the revised version:
___________
Lets say that you are making a few games, and you want to pack them all into one game. BUT WAIT! They all run on different framerates! This is whee this code comes in:

stage.frameRate = 12;

Now, in the code, you can change the 12 to whatever frame rate you want it to be, from 0.01 to 1000. Of course, no human eye can see a difference in anything than 70 fps or higher.

I will be making other tutorials as well as I get more into it.

Enjoy!


None

Lord-Sonx

Reply To Post Reply & Quote

Posted at: 5/4/07 06:51 PM

Lord-Sonx EVIL LEVEL 32

Sign-Up: 01/17/04

Posts: 8,871

couldn't you alter the apperence of framerate in as2?

oh, the human eye can see the different in framerate if it's highly trained.. it depends peson to person, i once read it was only 60fps.


None

Mehrdad14

Reply To Post Reply & Quote

Posted at: 5/4/07 06:54 PM

Mehrdad14 EVIL LEVEL 12

Sign-Up: 12/05/05

Posts: 1,330

stage.frameRate = 12;

wow very nice! Please do more!

Fate. Strength. Intelligence.


None

DFox

Reply To Post Reply & Quote

Posted at: 5/4/07 06:56 PM

DFox LIGHT LEVEL 30

Sign-Up: 08/09/03

Posts: 9,474

Awesome feature in AS3! I have to start learning it.

Nice tutorial.


None

KaynSlamdyke

Reply To Post Reply & Quote

Posted at: 5/4/07 06:59 PM

KaynSlamdyke LIGHT LEVEL 16

Sign-Up: 06/25/04

Posts: 4,926

I understand that as someone who's not touched AS3 yet that this is a bit presumptious of me...
But since when did explaining what a single property of a class does constitute as a tutorial?

Current build for ThreedeeTiles : Monkey
Previous: Lamprey, Mountain Goat (Dead Fork)


None

DFox

Reply To Post Reply & Quote

Posted at: 5/4/07 07:01 PM

DFox LIGHT LEVEL 30

Sign-Up: 08/09/03

Posts: 9,474

At 5/4/07 06:59 PM, KaynSlamdyke wrote: But since when did explaining what a single property of a class does constitute as a tutorial?

I don't agree because it's such a huge FEATURE that a wide range of people have been looking form. But yeah, just individual properties would be a little too much, but this property is very important and more of a feature anyway.


None

DarkMana

Reply To Post Reply & Quote

Posted at: 5/4/07 07:04 PM

DarkMana DARK LEVEL 23

Sign-Up: 04/04/05

Posts: 2,728

I don't understand why you can't make the framerate zero, it would be absolutely perfect for pausing games.

Asus P5Q PRO, Intel E8400 @ 3.60 GHz, 4GB DDR2-1000, ATI HD4850

BBS Signature

None

LesPaulPlayer

Reply To Post Reply & Quote

Posted at: 5/4/07 07:07 PM

LesPaulPlayer DARK LEVEL 12

Sign-Up: 05/18/06

Posts: 673

it just makes things go really really slow. If your not making a crazy fast game with tons of movement that will cause a player to die if he doesnt react within a couple of frame, it will work fine.


None

DFox

Reply To Post Reply & Quote

Posted at: 5/4/07 07:11 PM

DFox LIGHT LEVEL 30

Sign-Up: 08/09/03

Posts: 9,474

At 5/4/07 07:07 PM, LesPaulPlayer wrote: it just makes things go really really slow. If your not making a crazy fast game with tons of movement that will cause a player to die if he doesnt react within a couple of frame, it will work fine.

I'm not sure what you're talking about...

Do you mean dynamically changing the FPS slows everything down?


None

DarkMana

Reply To Post Reply & Quote

Posted at: 5/4/07 07:15 PM

DarkMana DARK LEVEL 23

Sign-Up: 04/04/05

Posts: 2,728

At 5/4/07 07:11 PM, DFox wrote: Do you mean dynamically changing the FPS slows everything down?

I think he's referring to my post, saying that making the FPS really slow would be sufficient for pausing.

Asus P5Q PRO, Intel E8400 @ 3.60 GHz, 4GB DDR2-1000, ATI HD4850

BBS Signature

None

LesPaulPlayer

Reply To Post Reply & Quote

Posted at: 5/4/07 07:19 PM

LesPaulPlayer DARK LEVEL 12

Sign-Up: 05/18/06

Posts: 673

At 5/4/07 07:15 PM, DarkMana wrote:
At 5/4/07 07:11 PM, DFox wrote: Do you mean dynamically changing the FPS slows everything down?
I think he's referring to my post, saying that making the FPS really slow would be sufficient for pausing.

well not exactly. A better way would be to remove event listeners, or just say:

if (!pause) {
}|


None

BasV

Reply To Post Reply & Quote

Posted at: 5/12/07 01:11 PM

BasV LIGHT LEVEL 20

Sign-Up: 05/07/05

Posts: 303

At 5/4/07 07:04 PM, DarkMana wrote: I don't understand why you can't make the framerate zero, it would be absolutely perfect for pausing games.

no it wouldn't. It would stop every code meaning you wouldn't be able to turn the games on again.


None

UnknownFear

Reply To Post Reply & Quote

Posted at: 5/12/07 01:32 PM

UnknownFear FAB LEVEL 34

Sign-Up: 02/27/04

Posts: 6,912

At 5/12/07 01:11 PM, B-Mantis wrote: no it wouldn't. It would stop every code meaning you wouldn't be able to turn the games on again.

You mean this wouldnt work:

Frame 1:

Guy dies. Pause game!
stage.frameRate = 0;

Button to go to next frame.

Frame 2:
stage.frameRate = 12;

Why can't the above scenario work?

Blog
[ T | F | G/MSN ]
--Ubuntu 9.10 "Karmic Koala" User--


None

LesPaulPlayer

Reply To Post Reply & Quote

Posted at: 5/12/07 01:32 PM

LesPaulPlayer DARK LEVEL 12

Sign-Up: 05/18/06

Posts: 673

At 5/12/07 01:11 PM, B-Mantis wrote:
At 5/4/07 07:04 PM, DarkMana wrote: I don't understand why you can't make the framerate zero, it would be absolutely perfect for pausing games.
no it wouldn't. It would stop every code meaning you wouldn't be able to turn the games on again.

FALSE 100%. the whole point of events is that its not everyframe, on ENTER_FRAME events. A keyDown event is registered every time the key is down, regardless of frame rate.


None

Mark2000

Reply To Post Reply & Quote

Posted at: 5/12/07 01:59 PM

Mark2000 EVIL LEVEL 07

Sign-Up: 07/20/04

Posts: 32

I don't understand how this works or I'm doing it wrong. Do you just put stage.frameRate = n; in a key frame and from that point on the framerate changes to whatever you put? Cause that's what I did and it aint working (and im outputing to flashplayer 9 w/as3.0).


None

Victory

Reply To Post Reply & Quote

Posted at: 5/12/07 02:13 PM

Victory EVIL LEVEL 30

Sign-Up: 12/24/06

Posts: 7,130

It was fantastic until I saw it was for AS3... Grrrr.

BBS Signature

None

Jindo

Reply To Post Reply & Quote

Posted at: 5/16/07 01:38 PM

Jindo LIGHT LEVEL 22

Sign-Up: 08/30/05

Posts: 1,789

I tested this pausing with the frame-rate, and there're 2 reasons why:

~Setting the FPS to 0 would make it look pretty crappy, since you can't have some kind of 'PAUSE' transition when you press the P key (0 fps = no movement).

~You wouldn't be able to un-pause (you would, because the lowest fps is actually 0.01, but it would take like 2 seconds to respond).

:D


None

BasV

Reply To Post Reply & Quote

Posted at: 5/17/07 03:55 PM

BasV LIGHT LEVEL 20

Sign-Up: 05/07/05

Posts: 303

At 5/12/07 01:32 PM, UnknownFear wrote:
At 5/12/07 01:11 PM, B-Mantis wrote:
Frame 1:

Guy dies. Pause game!
stage.frameRate = 0;

Button to go to next frame.

Frame 2:
stage.frameRate = 12;

Why can't the above scenario work?

framerate means: how many frames per second. A framerate of 0 would mean NO frames per second, so NO frames at all. It would just totally stop the code. That's why the framerate can't be lower than .1
When you press a button, you probably put code on that button right? Well a event that listens to mouse clicks is actually a onenterframe event. It checks whether the mouse is pressed EVERY frame. so again: buttons won't work with a framerate of 0.


None

pt9-9

Reply To Post Reply & Quote

Posted at: 5/22/07 10:19 PM

pt9-9 NEUTRAL LEVEL 10

Sign-Up: 10/05/05

Posts: 744

I can see many people using some sort of slow motion feature in games.

It would probably slow down audio too, either that or make it choppy.


None

ShortMonkey

Reply To Post Reply & Quote

Posted at: 5/22/07 10:36 PM

ShortMonkey DARK LEVEL 30

Sign-Up: 04/01/06

Posts: 7,221

Nice... I really need to get Flash CS3 soon.


None

s1nt3ch

Reply To Post Reply & Quote

Posted at: 5/23/07 12:04 AM

s1nt3ch EVIL LEVEL 09

Sign-Up: 07/02/02

Posts: 3,612

At 5/22/07 10:19 PM, pt9-9 wrote: I can see many people using some sort of slow motion feature in games.

It would probably slow down audio too, either that or make it choppy.

well not really, because just slowing the framerate would just make it seem choppy because your motions (such as movieClips) still only occupy a certain ammount of frames so all it would do is stop on each frame for longer without actually stretching any tweens you may have. You could possibly get away with it by using all AS to move everything on your screen. Oh man i wish i still had my slo mo game that i was making.

BBS Signature

None

Matt-Porter

Reply To Post Reply & Quote

Posted at: 8/31/07 07:59 PM

Matt-Porter FAB LEVEL 28

Sign-Up: 08/09/04

Posts: 1,064

I have an addition to this, I just tested it and im pretty sure 3 = 30, people might want to tknow that.

so if you want 30 fps you would use 3
12 fps would be 1.2, thats what im seeing as far as testing goes.

stage.frameRate= 1.2 //thats 12 FPS

correct me if im wrong, just going by observation.


None

crushy

Reply To Post Reply & Quote

Posted at: 3/23/08 07:21 PM

crushy LIGHT LEVEL 15

Sign-Up: 09/17/05

Posts: 1,842

It appears I can only change the stage's framerate, anyone else have this problem?

Learning AS3 :D
Help me fix Flash :(

BBS Signature

None

crushy

Reply To Post Reply & Quote

Posted at: 3/23/08 08:44 PM

crushy LIGHT LEVEL 15

Sign-Up: 09/17/05

Posts: 1,842

*Well-timed bump*

Learning AS3 :D
Help me fix Flash :(

BBS Signature

None

CaptinChu

Reply To Post Reply & Quote

Posted at: 3/23/08 08:50 PM

CaptinChu DARK LEVEL 15

Sign-Up: 09/11/05

Posts: 3,219

Can framerate be negative?

All programming problems can be solved with Arrays!

BBS Signature

None

crushy

Reply To Post Reply & Quote

Posted at: 3/23/08 08:53 PM

crushy LIGHT LEVEL 15

Sign-Up: 09/17/05

Posts: 1,842

At 3/23/08 08:50 PM, CaptinChu wrote: Can framerate be negative?

nope.

Learning AS3 :D
Help me fix Flash :(

BBS Signature

None

crushy

Reply To Post Reply & Quote

Posted at: 3/24/08 06:48 PM

crushy LIGHT LEVEL 15

Sign-Up: 09/17/05

Posts: 1,842

Last bump for mc framerate changing situation...

Learning AS3 :D
Help me fix Flash :(

BBS Signature

None

Moonkey

Reply To Post Reply & Quote

Posted at: 3/25/08 01:20 AM

Moonkey DARK LEVEL 07

Sign-Up: 05/11/07

Posts: 919

You can't change the framerate of individual MCs.


None

4as

Reply To Post Reply & Quote

Posted at: 3/25/08 11:35 AM

4as EVIL LEVEL 20

Sign-Up: 11/18/04

Posts: 32

At 5/4/07 06:44 PM, Siggles wrote: AS3: Main

stage.frameRate = 12;

Now, in the code, you can change the 12 to whatever frame rate you want it to be, from 0.01 to 1000. Of course, no human eye can see a difference in anything than 70 fps or higher.

Actually, human eye can perceive difference up to about 200Hz; 60-80Hz is when flickering disappears.

Also, there is something wrong with that property. I tried messing around with it (in early AS3 alpha release, though) and after a while it broke... the graphics were messed up, and script events didn't respond.


All times are Eastern Standard Time (GMT -5) | Current Time: 06:42 PM

<< Back

This topic is 1 page long.

<< < > >>
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!