Forum Topic: Flash 9, AS3, Browser performance

(493 views • 24 replies)

This topic is 1 page long.

<< < > >>
None

Kinsman

Reply To Post Reply & Quote

Posted at: 7/10/06 05:25 PM

Kinsman NEUTRAL LEVEL 14

Sign-Up: 07/15/00

Posts: 134

So I thought I'd take Flash 9 and try out its power. I decided to make a 'curtain fire' shooter; if you haven't played Perfect Cherry Blossom or Imperishable Night, it's a shooter that focuses on dodging impossible numbers of bullets that fly around in pretty patterns on the screen.

I did a prototype, it ran at 30 FPS. It was fine, but not all that exciting to watch or play. So I decided to 'perk it up' a bit by running it at 60 FPS - boom! It's gorgeous! The game's going to be hot when it's done, I can promise you that.

But I *can't* promise it'll be hot if you play it on Newgrounds. This is because you'd be playing the game in a browser, instead of in a standalone player. In a browser, the game drops to 40-50 FPS, with the accompanied slowdown. It just feels like it's suffering from permanent slowdown problems.

After the promises of Flash 9's improved scripting engine, I'm disappointed. :(

Thing is, it's not the Actionscript that's causing the trouble here. I did some timing tests, and in both the standalone and browser versions, moving hundreds of bullets and doing hundreds of collision tests only cost me about 1 millisecond.

However, when I do timing on the entire frame instead of the frame's code, a 60 FPS game runs at 16 ms per frame in the standalone (which is about right) and varies wildly from 18-30 ms in the browser.

Apparently, you can make the Actionscript engine as fast as you want, but you can't shake off the chains that the browser puts on Flash >:( , chains that are apparently there to cover fscommands or Javascript communication, or other stuff that I wish I could disable or get rid of somehow.

If you want a demonstration, head to
http://media.putfile../FireFlies-Prototype

and play the game.

Click the logo to start; use arrow keys to move, X to fire, Z to move slowly.
Shoot the demon 199 times before losing your three lives.
Your weakpoint is located in your head, be careful.

Then, download the file for yourself and play it in your Flash 9 standalone. (Technical details of how to directly download this file, and how to get your hands on a Flash 9 standalone are up to you, I'm afraid.) Witness the true power of 60 FPS Flash gaming in Flash 9.

I'm going to finish the game, slowdowns or not. I'll just have to put in a note, encouraging players to play it in a standalone player for themselves.

BBS Signature

None

Zac-Donald

Reply To Post Reply & Quote

Posted at: 7/10/06 05:36 PM

Zac-Donald FAB LEVEL 07

Sign-Up: 06/21/06

Posts: 2,319

yeah it jumps a lot but it plays fine
I like the game so far

PM me if you love me: 7
Newest love: the1stguy1 - He isn't a homo btw

BBS Signature

None

Disarray-yarrasiD

Reply To Post Reply & Quote

Posted at: 7/10/06 07:05 PM

Disarray-yarrasiD DARK LEVEL 08

Sign-Up: 11/14/04

Posts: 1,468

would you mind posting the code for that? I would like to see how different as 3.0 is in practise.

this would be really appreciated.

BBS Signature

None

Kinsman

Reply To Post Reply & Quote

Posted at: 7/10/06 07:15 PM

Kinsman NEUTRAL LEVEL 14

Sign-Up: 07/15/00

Posts: 134

At 7/10/06 07:05 PM, Disarray_yarrasiD wrote: would you mind posting the code for that? I would like to see how different as 3.0 is in practise.

this would be really appreciated.

Interesting thought. I don't want to give away the code to a project that I'm in the middle of, but when the game's finished and released, I think I will give out the source.

BBS Signature

None

Zac-Donald

Reply To Post Reply & Quote

Posted at: 7/10/06 07:25 PM

Zac-Donald FAB LEVEL 07

Sign-Up: 06/21/06

Posts: 2,319

give out some new codes

PM me if you love me: 7
Newest love: the1stguy1 - He isn't a homo btw

BBS Signature

None

Disarray-yarrasiD

Reply To Post Reply & Quote

Posted at: 7/10/06 07:25 PM

Disarray-yarrasiD DARK LEVEL 08

Sign-Up: 11/14/04

Posts: 1,468

lol

don't worry, I wont steal your game, I am working on a 3d one right now, I just wanted to see how certain things were done since 3.0 changed a lot of methods and syntax.

if you change you mind:

hotmailreallysucksbigtime@hotmail.com
or
reidg2@student.ednet.ns.ca

BBS Signature

None

GameSQUID

Reply To Post Reply & Quote

Posted at: 7/10/06 07:34 PM

GameSQUID NEUTRAL LEVEL 02

Sign-Up: 07/13/05

Posts: 95

To get a stable framerate in the browser, you should set your framerate a bit lower, to about 30 or 40. It won't be as fast as you set it to, but it will be more stable.
30-40 fps is more than enough for a 2D game, imho.


None

Disarray-yarrasiD

Reply To Post Reply & Quote

Posted at: 7/10/06 07:37 PM

Disarray-yarrasiD DARK LEVEL 08

Sign-Up: 11/14/04

Posts: 1,468

oh ya...

for some reason putting up the frame rate increases browser speed, even when the swf is not running at full.

BBS Signature

None

HaroFreak

Reply To Post Reply & Quote

Posted at: 7/10/06 08:20 PM

HaroFreak DARK LEVEL 42

Sign-Up: 02/10/01

Posts: 8,723

They claim to have a much faster processing rate, but I don't see much difference after testing some graphic-intense animations on my browser (Flash Player 9) and on the standalone player (Flash 8).

Status: MIA
Next Release ETA: ?


None

Disarray-yarrasiD

Reply To Post Reply & Quote

Posted at: 7/10/06 08:48 PM

Disarray-yarrasiD DARK LEVEL 08

Sign-Up: 11/14/04

Posts: 1,468

that would be because the browser is slower, and player 9 is designed to run 3.0 10x faster not 2.0

BBS Signature

None

Kinsman

Reply To Post Reply & Quote

Posted at: 7/10/06 09:07 PM

Kinsman NEUTRAL LEVEL 14

Sign-Up: 07/15/00

Posts: 134

I've just done some experiments, checking out the min-max frame times for various frame rates, in both the standalone and the browser.

It doesn't seem to matter what frame rate I choose - 50,40,30,20 - the browser will always add from 1 to 15 milliseconds to that frame time, screwing up the game with hiccups and slowdowns at any of the steps.

I know that this doesn't happen on ordinary movies. I'm guessing what's going on is that any actionscript that happens is mirrored by some processing in the browser, and the browser's processing isn't nearly as efficient. So, once the amount of actionscript reaches a certain level per frame, you have to deal with this problem - no matter how fast Flash 9 is. :P

BBS Signature

None

GameSQUID

Reply To Post Reply & Quote

Posted at: 7/13/06 07:54 PM

GameSQUID NEUTRAL LEVEL 02

Sign-Up: 07/13/05

Posts: 95

At 7/10/06 08:20 PM, HaroFreak wrote: They claim to have a much faster processing rate, but I don't see much difference after testing some graphic-intense animations on my browser (Flash Player 9) and on the standalone player (Flash 8).

Animations etc aren't faster at all - the graphics engine is relatively the same. It's code that's faster. For instance, path finding would be a lot faster (about 10 times faster if not more).
To get a slight increase in speed for graphics, use sprites instead of movieclips, and use cacheAsBitmap where needed (not on things that change a lot, that will actually slow things down). cacheasbitmap is also available in Flash 8 in case you didn't know.


None

JD77

Reply To Post Reply & Quote

Posted at: 7/13/06 07:56 PM

JD77 NEUTRAL LEVEL 17

Sign-Up: 03/30/05

Posts: 1,062

Are u declearing ALL the variables? if not then thats the reason u sence no difference.

*User Page under construction*

BBS Signature

None

HaroFreak

Reply To Post Reply & Quote

Posted at: 7/13/06 08:06 PM

HaroFreak DARK LEVEL 42

Sign-Up: 02/10/01

Posts: 8,723

At 7/13/06 07:54 PM, GameSQUID wrote: Animations etc aren't faster at all - the graphics engine is relatively the same. It's code that's faster.

I am aware of that. The point I am emphasising on is that the Adobe site related to said topic claimed that graphics are processed faster despite no visible difference.

To get a slight increase in speed for graphics, use sprites instead of movieclips, and use cacheAsBitmap where needed (not on things that change a lot, that will actually slow things down). cacheasbitmap is also available in Flash 8 in case you didn't know.

I don't see any need to use it nonetheless.

Status: MIA
Next Release ETA: ?


None

Kinsman

Reply To Post Reply & Quote

Posted at: 7/13/06 08:17 PM

Kinsman NEUTRAL LEVEL 14

Sign-Up: 07/15/00

Posts: 134

A reasonable success!

I discovered that there is two kinds of slowdown in Flash - one where the Flash tries to process each and every frame, while the total game speed slows down; and one where it tries to sync with streaming sound, where it drops the visual display of individual frames, but STILL DOES THE GAME PROCESSING EACH FRAME AND MAINTAINS THE OVERALL GAME SPEED.

My game is saved! All I have to do is stream and loop a small bit of silence somewhere in the movie, and everyone can play the game as it was meant to be! :)

BBS Signature

None

HaroFreak

Reply To Post Reply & Quote

Posted at: 7/13/06 08:21 PM

HaroFreak DARK LEVEL 42

Sign-Up: 02/10/01

Posts: 8,723

At 7/13/06 08:17 PM, Kinsman wrote: My game is saved! All I have to do is stream and loop a small bit of silence somewhere in the movie, and everyone can play the game as it was meant to be! :)

I tried that, but it appears to be an incomplete solution (based on my own experiments).

Status: MIA
Next Release ETA: ?


None

jcom

Reply To Post Reply & Quote

Posted at: 7/13/06 08:33 PM

jcom NEUTRAL LEVEL 10

Sign-Up: 09/19/04

Posts: 322

It sounds good to me? Whats wrong with streaming the sound.


None

HaroFreak

Reply To Post Reply & Quote

Posted at: 7/13/06 08:34 PM

HaroFreak DARK LEVEL 42

Sign-Up: 02/10/01

Posts: 8,723

At 7/13/06 08:33 PM, jcom wrote: It sounds good to me? Whats wrong with streaming the sound.

Filesize increase is one factor since every time you use a sound effect it accumulates.

Status: MIA
Next Release ETA: ?


None

dELtaluca

Reply To Post Reply & Quote

Posted at: 7/14/06 01:34 AM

dELtaluca LIGHT LEVEL 20

Sign-Up: 04/16/04

Posts: 5,117

At 7/13/06 11:42 PM, -cherries- wrote: omg, that was amazing.
how'd you get key pressing to work?

since AS3 doesnt have an isDown for security reasons (WTF?) you have to make youre own, i encapsulated it into a nice little class that i can use, but its very easy to make youre own, so i wont give it out

My social worker says im special!

BBS Signature

None

GameSQUID

Reply To Post Reply & Quote

Posted at: 7/14/06 05:27 AM

GameSQUID NEUTRAL LEVEL 02

Sign-Up: 07/13/05

Posts: 95

At 7/13/06 08:06 PM, HaroFreak wrote:
At 7/13/06 07:54 PM, GameSQUID wrote: To get a slight increase in speed for graphics, use sprites instead of movieclips, and use cacheAsBitmap where needed (not on things that change a lot, that will actually slow things down). cacheasbitmap is also available in Flash 8 in case you didn't know.
I don't see any need to use it nonetheless.

No reason to use what? Sprites? You should, because they're faster than movieclips, and should be used for everything that doesn't have a timeline (you can still attach movieclips to it that do have a timeline).
If you meant no reason to use cacheAsBitmap, well, in some cases it can be extremely useful. In my scrolling tile engine, I cache entire layers as bitmaps (I only have the necessary tiles attached to them off course), and the speed increase is fenomenal. Just remember to set it to false if you're doing a lot of operations on the displayobject for a while, and set it to true again when you're done.


None

HaroFreak

Reply To Post Reply & Quote

Posted at: 7/14/06 08:14 AM

HaroFreak DARK LEVEL 42

Sign-Up: 02/10/01

Posts: 8,723

At 7/14/06 05:27 AM, GameSQUID wrote: No reason to use what? Sprites? You should, because they're faster than movieclips, and should be used for everything that doesn't have a timeline (you can still attach movieclips to it that do have a timeline).

So what if they are faster than vectored images if they fail to achieve what I want?

Status: MIA
Next Release ETA: ?


None

GameSQUID

Reply To Post Reply & Quote

Posted at: 7/14/06 08:21 AM

GameSQUID NEUTRAL LEVEL 02

Sign-Up: 07/13/05

Posts: 95

At 7/14/06 08:14 AM, HaroFreak wrote:
At 7/14/06 05:27 AM, GameSQUID wrote: No reason to use what? Sprites? You should, because they're faster than movieclips, and should be used for everything that doesn't have a timeline (you can still attach movieclips to it that do have a timeline).
So what if they are faster than vectored images if they fail to achieve what I want?

I'm not saying you should use them all the time. Just keep in mind that they're there and that they're faster, which is nice.

You're complaining that Flash9 display isn't faster - all I'm saying is that it can be a bit faster if you use sprites. It might not be possible to use them in your particular situation, but it's still something that's making Flash9 faster, whether you like it or not.

Oh, and by the way, I'm pretty sure you can use sprites with vector images as well. Just make a class that extends sprite, and map that to a library item. If I'm not mistaking, you'll have a vector-based display object, but it won't have a timeline. Haven't tested this though, so I could be wrong.


None

HaroFreak

Reply To Post Reply & Quote

Posted at: 7/14/06 08:36 AM

HaroFreak DARK LEVEL 42

Sign-Up: 02/10/01

Posts: 8,723

At 7/14/06 08:21 AM, GameSQUID wrote: You're complaining that Flash9 display isn't faster - all I'm saying is that it can be a bit faster if you use sprites. It might not be possible to use them in your particular situation, but it's still something that's making Flash9 faster, whether you like it or not.

I did mention that I would prefer to sacrifice smooth factor to make my designs look right.

Status: MIA
Next Release ETA: ?


None

Blaze

Reply To Post Reply & Quote

Posted at: 7/14/06 10:14 AM

Blaze LIGHT LEVEL 22

Sign-Up: 08/04/05

Posts: 6,957

Thats so fucking awesome. The wonders of AS3.


All times are Eastern Standard Time (GMT -5) | Current Time: 08:30 AM

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