I want to make my little flash project a little faster, and I have a question - is it better to have just one onClipEvent(enterframe) rather than several? or does it not matter?
Also, have any tips on CPU traps? (I’m talking about things that use the CPU too much…)
thanks
Multiple onClipEvent(enterFrames) is more CPU usage. So the more you have in one spot, the slower your movie can be.
Having too many tweens in one area can also be CPU draining. Some people think that a lot of little tweens around their layout is fine, but in actuality, this just makes your site lag a bit more on slower machines (and probably makes it more distracting).
If you have your FPS too high it can actually lag on some systems because they can’t process it fast enough, there have been multiple discussions on this and I say any FPS up to around 30ish should be good.
If you have a partially transparent .png image (if it was exported as partially transparent) and you use it in tweens, or move it with AS, depending on the image it can cause lagging. Flash has to interpret the information in the image to be able to keep it transparent like that and that uses CPU resources. This is not to say .pngs in Flash are bad… nope, I love .png images (my footer uses them even), but just be careful on how you use them and how big they are.
This is all I can think of now.
*Originally posted by lostinbeta *
Multiple onClipEvent(enterFrames) is more CPU usage.
Can you back that up, Lost? Because there was a discussion about this between us French, and I still haven’t seen any tangible proof of that. C:-)
I think I remember that being mentioned on here before. And… well…, why wouldn’t it be? Wouldn’t the enterFrame be constantly be running and using the CPU resources? And then wouldn’t it get worse and worse the more you have running at the same time?
Well… I am going against Ilyas here… so I am going to lose either way… but I don’t get how it wouldn’t be.
[edit]yeah… I want to go on record and say that several clips running is probably fine, but I am talking about a lot of clips running at the same time[/edit]
Sorry, I misunderstood what you said. I thought you were saying that several onEnterFrame (one per clip) take more ressources than one big onEnterFrame (for all the clips). Probably because we were talking about it.
:trout: myself
pom :hangover:
Oh ok… well in that case…
I think it would be the same amount.
I mean, you can run several onEnterFrames at once, but it is still processing the same amount of data, so running it all under 1 onEnterFrame will still be processing the same thing, just under one onEnterFrame instead of multiple ones.
That is my opinion of course… I am not exactly Flash Tech Support Whiz here.
Well… Here you go…
Get rid of transparency… Anything with a transparency setting… will make the machine run at more computations.
Stay away from loading in .jpg’s and the such… Any outside source requires your Flash Player to computationally move it around using that particular set of compiling code… That takes time…
Math is slow… Period… hehe…
Having multipla onEnterFrames would slow it down… If I have one ball bouncing around and I have 30 balls bouncing around… Which would be faster?
To make everything better optimized I’d suggest the use of more data holding and functions… COmputers almost come standard with 64mb RAM or higher now… And that’s alot of memory for you to use! So use varaibles alot… If you have 20 variables… Instead of using alot of math equations you’ll notice the speed difference.
Like… sin and cos for example… Make a look-up table instead of using the Math.sin and Math.cos methods. Then just look up int he array sinTable[45] as in 45 degrees…
Get it?
um, what about loading an external swf? check out this place
http://web.mit.edu/lavaboy/www/newsite.html
if you click on play/pause, (which toggles play/stop of the swf I’m loading…) you’ll see the animation on the bubbles is better… I’m using an onClipEvent(enterframe) as the loop that animates the bubbles… I would like the animation to be smooth as I play the swf… any ideas?
(Note… I’m not streaming an MP3, I’m streaming a swf with sound embedded… would there be a difference?)