Flash Player Performance

30 posts

Flag Post

I’d like to start a thread about the performance issues of the flash player (especially in a browser) which in my point of view every flash game developer will have complained about at some point. So my question is: What are your strategies to speed up the framerate of your flash games?

To start off here’s a nice blog article about display programming optimizing in ActionScript.

Flag Post

Well, here is a few basics: It slows down more as you begin to add, like, over 30 movieclips to the stage, because all movieclips take a certain amount of resources. It helps to not attach/remove things continually from the library since that puts some stress on the garbage collector in the flash virtual machine. If you use lots of alpha settings you will eat up processor; same with high-quality blur, and also using multiple onEnterFrame handlers. All bad for speed.

Vectors also take up more processing power to draw (especially lines), since the calculations need to be made to draw it every frame, so bitmaps can be faster, but are more difficult to scale and rotate.

My games so far have been based on the onEnterFrame handler, so I try to keep to these rules. But, I am investigating a better way to manage game framerates by using intervals.

Flag Post

Indy is all right, delete the onEnterFrame things when it’s not useful ad think about how you can optimize the game. For instance, in rotazion and danztyle, mine and arrow are not destroyed and then regenerated at the top / right, just moved the _y / _x so it starts again.

Flag Post

The people over at Metanet seem to have written the best straightforward tutorials on game design that I have seen, personally. (and I like how they used flash examples to illustrate their maths)

Here is the link. Check it out.

Flag Post

Indy, thanks for the Metanet Link. Seems very interesting!

Another question to the forums: Has anyone used an approach yet drawing all (bitmap) graphics manually to a fullscreen bitmap every frame, instead of using a lot of attached movieclips or sprites?

Flag Post

I know a strange incantation that makes the flash player go faster.

Well it seems to go faster on my machine, apparently going into full screen mode then back again removes some sort of frame rate limiter.

I might be imagining it but try doing this.

go here cutandpaste my strange urls are not appreciated here


make sure the flash game is selected and press – this will shrink the game a little bit and display a frame rate in the top left hand corner.

now right click and choose toggle full screen mode from the menu, it should then jump into full screen mode

press esc or do the menu thing again to get back out

Observer the diference in frame rate, or maybe not if I’ve just gone a bit crazy :)

This is on a PC with flash player 9,0,28,0 , if you have a reasonable machine and the game is already running at its full 30fps easily I’d guess that you wouldn’t notice it getting faster but for me it goes about 8ms a frame faster from doing that.

Looks like the flash player is limited when in a browser, they remove this when it goes full screen as it really needs the extra ooomph but forget to put it back when you return to windowed mode.

Flag Post

i have 20-21fps default and after trick ~27fps. so you arent crazy or we both are.

how you exactly do fullscreen switch?

Flag Post

Mh… I have an 1.33ghz Powerbook and it runs in 14fps – before and after the fullscreen switch.

Flag Post

Interesting, I tried the full screen switch and here’s what I got:

normal (before full screen): 22-23 fps | during full screen: 24-27 fps | normal (after full): 22-25 fps

Conclusion: For me, the difference was much more subtle, and it definitely ran a little faster during full screen mode, but not much difference otherwise (my computer is very fast, too, and I run Flash Player 9). I will suggest that a difference in PC makes a difference in frame rate.

But, has anyone noticed the difference between Firefox and IE?? I hate to say it, but, IE runs Flash way better than Firefox, to the point where I use it exclusively for my testing. Any thoughts on that?

Flag Post

My guess about IE vs Firefox is that ActiveX components have more direct access to system resources, and have to go through less hoops. Total speculation but that is my experience after writing components for both IE and Firefox.

Flag Post

I get 30 fps fullscreen and only 15 fps fullscreen, but thats because I have a really large screen and so the fullscreen change bogs down the player.

Flag Post

IE vs Firefox:
Fx puts limits on plugins so they can’t eat all resources and make Fx “not responding”. There was a link some time ago in chat but i can’t find it now.

Flag Post

dxOne nailed it, I’ve spent quite some time trying to figure out why my Mac Pro of all machines can’t play Fancy Pants Adventures in Firefox, Safari, Firefox in windows, or Internet Explorer in windows at 30 fps, yet it will run at 120 fps in the standalone player. There’s an Adobe blog that goes through this, then explains that shockwave, quicktime, and windows media can run such CPU intensive tasks because they run in a different thread, while Flash doesn’t. I think this is completely ridiculous, especially if they ever expect Flash to be anything more than an annoying as hell advertisement program. Anyone have anyone’s email at Adobe/Macromedia? I want to go yell at someone.

Any gaming site that takes itself seriously is going to have to start offering zipped swfs for download until Adobe gets its act together. I’m pretty pissed at browser’s throttling practices too, especially since so many computers are shipping with multiple CPUs nowadays.

Flag Post

for dx0ne, the fullscreen code, its restricted when you can change the fullscreen state and inside the menu handler seems to be the safest place to put it. So this snippet should just work assuming kongregate doesn’t kill it by reformatting

var cm;
var cmi;
var f;
cm = new ContextMenu();
if( Stage[“displayState”] == “normal” )
Stage[“displayState”] = “fullScreen”;
Stage[“displayState”] = “normal”;
cmi = new ContextMenuItem(“Toggle fullscreen mode.”, f );

Flag Post

I also poked it a bit more and noticed something else.

in opera it doesn’t make any difference


just by right clicking to display the context menu has the same speedup effect whilst the menu is displayed

Flag Post


flash is mostly filtrate limited, the speed is more dependent on area displayed than anything else. I’m pretty certain the slowness in some browsers rather than others is all down to screen buffer management and the main speedup from standalone display comes from exactly the same place. Even just using a hardware blit in the most obvious places would make a huge difference things don’t have to be 3d to get basic GPU speedups.

As for someone to hassle I’d point you at this guy as someone who is probably easy to get on side, http://www.onflex.org/ted/index.php , but I doubt it will do much good :)

But the whole as3 thing shows they are more interested in code performance issues than frame rate (which are not the same), its their whole flex plan for world domination.

Flag Post

I can confirm what XiXs said about screen buffer management affecting Flash performance, because of my experience with Q-Zoid (game I made). When run in a browser at full size (700 × 700), it is very slow. When I reduce the size to 350×350 (taking up 1/4 of the original size) it runs way faster. Why? The code has not changed, neither has the vector graphics. I think XiXs has correctly identified one likely culprit: the browser’s screen buffering management. Although what Dr.Nero said about running in busy threads can’t help things any.

Geez, you’d think they could make it work at least as good as Shockwave, considering it’s the ‘standard’ for games, and all.

My question to XiXs: can you accomplish a hardware blit in Flash? Have you tried it, and if so are you willing to share the basics with me?

Flag Post

Indy, flash will do that inside or outside of a browser. That is the nature of rendering, especially so with Flash. That is not to say that browser management does not aggravate the problem. Every layer of control over the Flash player creates problems.

However, frame rate decrease is an issue largely with the activeX control regardless of where it plays.. even in applications like Zinc. I believe part of it can be corrected by Adobe themselves (as they have done in the past). Some of the independent browser issues need other solutions.

Flag Post

Indy, flash will do that inside or outside of a browser.

Ok, I believe you, because it makes sense to me (I would like to know more about the technical aspects of vector rendering, but I only understand the basic theory); however, it would seem to contradict the previous discussion, wherein it was mentioned that full screen actually makes it run faster, at least in the case of XiX’s game running in a browser.

Does anybody have some practical suggestions for overcoming these limitation?

Flag Post

Yeah, use bitmapCaching like it’s going out of style.

Flag Post

Here DrNero, you can contact Macromedia here. http://www.adobe.com/macromedia/contact/
But I wouldn’t advise yelling at them… just a thought :D

Flag Post

(I would like to know more about the technical aspects of vector rendering, but I only understand the basic theory); however, it would seem to contradict the previous discussion, wherein it was mentioned that full screen actually makes it run faster, at least in the case of XiX’s game running in a browser.

Whether its vector or bitmap rendering, more pixels = more render time. For example 640×480 = 307,200 pixels, whereas 1024×768 = 786,432 pixels. In the case of a big screen like mine (1920×1200), fullscreen = 2,304,000 pixels, 7.5 times more than rendering at 640×480. Thats why if I go fullscreen or run a game at full resolution, it will slow down since it has to calculate what each of those 2.3 million pixels should look like, based on the data in the game (whether vector or bitmap). With flash unfortunately full screen usually means just scaling the game up to the screen size, whereas with DirectX games the monitors resolution is often lowered to reduce the burden on your system.

The simplest thing done now is bumping your framerate up past your target fps since you know it will lose a percentage when run in the browser. If you want 30 fps, you may have to set it to 35, etc. The adjustment tends to change sometimes after player releases, so just test it out. No one should really be running a flash browser game at 120 fps anyway, unless its a very special situation.

Flag Post

I’ve done some test with regular movieclips and then enabling the cacheAsBitmap options. The cache improves performance (and number of items that can be on the screen) by 5-10×.

However, that was when I was using static characters. Now I have animated characters and this kills the benefits of the cacheAsBitmap… probably even slowing it down since it is continually contructing new Bitmaps.

Many of my character animations are only 10 frames that loop. Is is possible to cache each frame so I can get the animation and also the massive performance boosts?

Anyone know of some tutorials that reference this?


Flag Post

Just a little side note to add is that it is also good to create flowcharts before the programming process. I know that most of the programmers around the globe don’t do this but trust me. It helps a lot since you learn to reuse code and not making extra coda that would slow process and add file size.

Sure making flowcharts take time (depending on the application) but its worth it and its helped me a lot! For beginners this is a great method and for intermediate/advanced it is also good.

Thanks for the Full Screen code!

Flag Post

Hey everyone – thought I’d throw my two cents in about bitmaps. We’re having some good luck with blitting graphics from a sprite sheet onto a screen-sized bitmapdata object, and not using any movieclips at all. It runs loads better than with movie clips, with or without CacheAsBitmap. It’s way more abstract with no movie clips or frame-based animation though — but that performance boost is worth it! Runs great in a browser too, though you have to be clever with dumping the bitmaps because they eat up loads of RAM.