- Author had a File in an Envato Bundle
- Author had a Free File of the Month
- Author was Featured
- Beta Tester
- Bought between 10 and 49 items
- Exclusive Author
- Has been a member for 4-5 years
- Item was Featured
- Microlancer Beta Tester
Hi all,
I’ve been struggling with performance with my last file. I followed a number of great articles about reducing Flash’s cpu usage:
http://www.calypso88.com/?cat=7 http://osflash.org/as3_speed_optimizations http://www.richnetapps.com/as3-performance-optimization/
, and managed to improve speed with a few simple changes:
- Used int instead of Number whenever possible
- int( _number + 0.5 ) instead of Math.ceil(_number)
- an array of numbers between 0 and 1, randomized at the initialization phase, instead of Math.random each time I need a random number.
The articles go on to explain Bitwise shift operations as an excellent way of speeding up your file, but it’s just beyond me at this stage. Maybe BitFade can explain it, I’m sure he knows it inside-out 
One of the things I keep trying ( and failing ) is adding some periodic particle effects. I started with about 100 MovieClip-based particles to go along with an already MovieClip heavy stage. Whenever they start appearing the entire game slows down at least 30%, and once they’re gone it’s back to normal ,so I guess there are no memory leaks.
What’s your take on this? Anyone got more tips?
- United States
- Has been a member for 4-5 years
- Exclusive Author
- Author was Featured
- Sold between 50 000 and 100 000 dollars
- Item was Featured
- Contributed a Tutorial to a Tuts+ Site
- Author had a Free File of the Month
I think some of the optimization tips will help, but particles still take up so much memory optimization won’t help much. Maybe you could change the quality temporarily. Like change it to medium for your particle animation, and then back to high when they’re done. Also, maybe temporarily disable your movie while the particle animation happens. Like removing any enter frames and timers that might be firing.
- Sold between 100 000 and 250 000 dollars
- Author had a File in an Envato Bundle
- Has been a member for 4-5 years
- Author had a Free File of the Month
- Won a Competition
- Author was Featured
- Item was Featured
- Bought between 10 and 49 items
math optimization are only necessary in rare cases.
if your app is slow with 100 particles, then you have to change the way particles are rendered.
instead of using vectorial movieclips, render a single mc once in a bitmap and then use fast bitmapDatas functions to duplicate.
- United States
- Has been a member for 4-5 years
- Exclusive Author
- Author was Featured
- Sold between 50 000 and 100 000 dollars
- Item was Featured
- Contributed a Tutorial to a Tuts+ Site
- Author had a Free File of the Month
Check out this section in this article about cpu optimization. It talks about particle optimization.
http://help.adobe.com/en_US/as3/mobile/flashplatform_optimizing_content.pdf
- Has been a member for 4-5 years
- Author was Featured
- Contributed a Tutorial to a Tuts+ Site
- Netherlands
- Community Moderator
- Microlancer Beta Tester
- Sold between 10 000 and 50 000 dollars
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Exclusive Author
I went through quite a lot of optimization with my latest file (poker simulator) as it contained functions that had to be looped as much as possible in the shortest period of time. The main conclusion I reached was that bitwise operators are awesome, that it’s great to waste an array on being able to cancel out a lot of if-statements, and that you should always define variable types (and use int!) 
Check this blog post. Here are a lot of great tips about flash optimization. http://www.lostinactionscript.com/blog/index.php/talks/
for the particle, 100 particles shouldn’t cause much slow so I guess the particle graphics is complex or it have alpha channel?
While the particle graphics is complex and it is vector graphic maybe you can consider transfer it to BitmapData before or when runtime.
And it is better not use alpha graphic in particle, the reason is obvious, also something like GlowFilter ShadowFilter shouldn’t apply to particle itself, if it is needed for better visual performance, maybe apply it on container of particles.
And use minimum requirements of super Class for particle, if there is no need of timeline animation inside particle, use Sprite instead MovieClip 
Btw, if some particle effect is really heavy load, and that effect don’t need to be loop, maybe replace it with bitmap animation or pre draw it into bitmap animation in game initiate phase is a solution, use file size / memony to trade with CPU .
Hope these helps 
Particle can be tricky this is why there is no much use in them in flash project they take to much, but i can state the same thing about 3D engines, on the action time they take what they take. But practical have a great use in game but they have to pup up for short term and regenerate
But you can make your on little rendering, but it’s up to how much coding you have under your belt.
If you don’t have your own particle engine you can work with stardust-particle-engine.
http://code.google.com/p/stardust-particle-engine/
But it’s little big for my taste and i don’t think i have seen a use of it on AD but it’s really good and simple to work with.
Also you can work with frocessing class really great and light like.
• ColorHSV;
• F5Graphics.
but more imported is what you do when your particle are gone, you need not to make sure they are killed ,you need to confirm particle assassination 
- Author had a File in an Envato Bundle
- Author had a Free File of the Month
- Author was Featured
- Beta Tester
- Bought between 10 and 49 items
- Exclusive Author
- Has been a member for 4-5 years
- Item was Featured
- Microlancer Beta Tester
Wow! So many useful responses.
I’ve been disconnected from phone and internet for the last couple of days ( scary experience really
), so sorry for not responding earlier.
I made some more performance improvements by swapping all vectors with bitmaps, which made the file a little bigger ( from 300k to 400k ) but it’s worth it. Only downside is without vectors I can’t scale objects without losing image quality ( with vectors I can scale all I want and the objects still looks good ).
Also, I added a dynamic quality check, so on the heavier sections the whole game goes to “low” quality, and back up to high when there’s less stuff happening at once. Problem is, the game is almost always on “low” now, probably an indication of bad coding on my side.
