This content has been marked as final. Show 8 replies
you probably are not going to benefit from enabling the cacheAsBitmap property of your leaves and parts because it looks like those movieclips are changing frames.
that leaves you with 1440 operations and, depending upon how many of those hitTests resolve to true, up to 1440 tweens with EACH onEnterFrame loop. that's going to drain most cpus.
if you made a movieclip with say 10 leaves that rotate you could then have just 14 movieclips on stage and still have your 144 leaves and come close to having the same effect. that would result in much less cpu usage.
Yeah, I thought of making only 10 mcs also. This might be what I have to do but it has a less fluid appearance, obviously. I imagine I will have to experiment with several scenarios until I get what I'm looking for without the drain. I am unfamiliar with particles or any other method that might help to generate something more fluid. Basically, I'm trying to get it so show a ripple effect as the wind moves across the tree since wind doesn't always hit everything all at once unless there's a squall.
Just thought I'd pick brains on possiblities of some other method to achieve this effect. But maybe Flash is not capable of a work-around for this yet. I am wondering if AS3 can handle something like this better???
i don't know of anything coming in flash 3 that would help in this situation.
if you use a movieclip consisting of 10 leaves, the 10 leaves can each have different tweens/animations and they can all be clustered near one another.
you can introduce a random element so each instance of this movieclip will have different leave motions (so, each cluster of leaves responds to the wind differently).
the above should allow an effect similar to the one achieved with individual leaf animations with significantly reduced cpu drain.
I'll try that. So, even though there will still be 100 individual clips that are tweening, it's less stress on the CPU than detecting hittest? What about my situation is draining the CPU? Is it because of the onEnterFrame/hittest across so many mcs? Of course I don't really understand which processes add to the drain and which ones are reused.
I am considering getting rid of the hittest altogether. I only used it originally because I thought I could set a response across multiple clips and vary the "shape" of the wind to make it appear more natural without creating different tweens for each wind instance. Plus it seemed like a lot less work and, in the end, I think we all would like to achieve quicker results with code.
Thanks for helping me get to the bottom of this problem.
no, you would not have 100 movieclips. you would have 10 movieclips each containing 10 leaves that you animate. if you're animating them using the actionscript tween class, that won't work (and is an additional source of cpu drain not apparent in the above code).
if you're animating the leaves using timeline tweens that above would decrease cpu utilization.