715 posts
  • Author had a File in an Envato Bundle
  • Most Wanted Bounty Winner
  • Sold between 50 000 and 100 000 dollars
  • Author had a Free File of the Month
  • Exclusive Author
  • Has been a member for 6-7 years
  • Beta Tester
+3 more
majd_abdul says

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 :D

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?

5311 posts The Dude Abides
  • United States
  • Exclusive Author
  • Has been a member for 5-6 years
  • Elite Author
  • Bought between 100 and 499 items
  • Referred between 100 and 199 users
  • Author had a Free File of the Month
+5 more
CodingJack says

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.

1999 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Author had a File in an Envato Bundle
  • Has been a member for 5-6 years
  • Author had a Free File of the Month
  • Won a Competition
  • Bought between 10 and 49 items
+4 more
bitfade says

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.

5311 posts The Dude Abides
  • United States
  • Exclusive Author
  • Has been a member for 5-6 years
  • Elite Author
  • Bought between 100 and 499 items
  • Referred between 100 and 199 users
  • Author had a Free File of the Month
+5 more
CodingJack says

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

3671 posts Community Moderator
  • Has been a member for 5-6 years
  • Contributed a Tutorial to a Tuts+ Site
  • Netherlands
  • Community Moderator
  • Envato Studio (Microlancer) Beta Tester
  • Sold between 10 000 and 50 000 dollars
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Exclusive Author
+4 more
Joost Volunteer moderator says

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

271 posts
  • Bought between 1 and 9 items
  • Contributed a Tutorial to a Tuts+ Site
  • Europe
  • Exclusive Author
  • Has been a member for 4-5 years
  • Sold between 5 000 and 10 000 dollars
07happydays says

Check this blog post. Here are a lot of great tips about flash optimization. http://www.lostinactionscript.com/blog/index.php/talks/

111 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Sold between 1 000 and 5 000 dollars
  • Taiwan
savorks says

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

4140 posts
  • Bought between 1 and 9 items
  • Brazil
  • Exclusive Author
  • Has been a member for 6-7 years
  • Referred between 1 and 9 users
  • Sold between 5 000 and 10 000 dollars
tsafi says

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 :P

715 posts
  • Author had a File in an Envato Bundle
  • Most Wanted Bounty Winner
  • Sold between 50 000 and 100 000 dollars
  • Author had a Free File of the Month
  • Exclusive Author
  • Has been a member for 6-7 years
  • Beta Tester
+3 more
majd_abdul says

Wow! So many useful responses. I’ve been disconnected from phone and internet for the last couple of days ( scary experience really :D ), 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.

by
by
by
by
by
by