Thanks for the good tips. Actually this is an extended example of the
FriendsOfED-foundation as3-animation. I was trying to use the same kind of
coding as the author has (not very successful i think). The balls are simple
black circles, with a a glow effect on it. And the position of the ball
changes all the time, as well as the color of the glow. The motion is
actually simple springing. The springing target changes every 1 s (or .5),
so the balls spring towards the target. I found out that it forks much
slower, if the new target point is very far away from the old one (looks
like AS3 has still many problems with calculation higher values).
I prefer to stop talking, as you can see it by your own.
Here's a ZIP of it, if you couldn't download the files separately.
http://www.humyo.com/F/2000999-218668805  (you don't have to register to
download it).

As the color of the glow is defined by a Math.random()*color function. Would
it maybe be faster to enter some values of colors in an array and them chose
one of them, instead of calculation a new random each time?

Any more help appreciated.


*Pedro D. Kostelec*
[EMAIL PROTECTED]



On Fri, Oct 10, 2008 at 1:15 PM, sebastian <[EMAIL PROTECTED]> wrote:

> hi Pedro, bitmapcaching would make it MORE processor intense, not less.
>
> Visited your web page, but I can't seem to download... is this option only
> possible if I am registered? You might just want to give a link to a zip
> file instead - simpler.
>
> Things to check in general:
>
> 1. how you are animating the objects: use a controlling MC that triggers
> each ball to move, instead of having each ball do an 'onEnterFrame' can help
> tremendously: but that's not always possible.
> 2. Make your balls simpler: no outlines, no gradients, no alpha gradients,
> alpha:1 or 100 [AS3 or AS2]
> 3. reduce quantity or reduce frequency of new ball generation/updates.
> 5. Avoid calling floating numbers, round them up to integers when possible.
> 6. Use multiplications over divisions and use bit operations instead of
> both, when possible. 10/2 is slower than 10*0.5 which is still slower than
> 10>>1.
> 7. Optimize if-then statements so that you first check for the least/most
> common occurance
> 8. optimize if-then statements so that you don't check the same object more
> than once [this can occur in badly written hit collision tests]
>
> and more... there are lot's of options and pitfalls to good code vs bad
> code...
> :P
>
> You can also check the net work similar code done by others, there is a
> heap of bouncing ball examples all over the place. Try respected sources
> like 'friend of ed' and 'oriellies' for code you know has been well thought
> out, or from a good blog where its a pro who is illustrating things.
>
> Modifying their code will be a  lot easier and less prone to
> processor-loads that could occure when you are coding from scratch and not
> sure what the best way to program it is...
>
> hope some of this input was useful.
> :)
>
> Seb.
>
> Pedro Kostelec wrote:
>
>> Hi list
>>
>> I have created some balls being moved randomly (not completely) over the
>> stage, with a Glow Effect of 100,100 blur. All this together is very CPU
>> intensive. I just wondered if someone could check my files, and tell me
>> how
>> to optimize it, to work faster and use less CPU? Would bitmap cache do the
>> work? I have 0 experience with bitmap cache, so if it would help, could
>> you
>> tell me a link to a good tutorial or a good piece of code?
>> Here you can download my files:
>> http://www.humyo.com/2000999-217133957  (Right click on each file
>> separately
>> and chose download)
>>
>> Thanks
>>
>>
>> *Pedro D. Kostelec*
>> [EMAIL PROTECTED]
>> _______________________________________________
>> Flashcoders mailing list
>> [email protected]
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>>  _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to