On 4/9/06, Helen Triolo <[EMAIL PROTECTED]> wrote: > If array lookup (mysin[some-calculated-angle]) is faster than whatever > Flash uses to find Math.sin(some-calculated-angle) --you could write a > loop to test that, since I don't know if it's true-- then the simplest > thing would be to write (in a dummy fla) a loop to dump the contents you > need (in the format/precision you need it) to the output panel and then > paste that into the as file to create the array.
It is faster, mySinTable[ angle ] takes only a minuscule amount of time longer than Math[ "sin" ], which wouldn't even have called the function yet, and calling the function will take longer than evaluating the register where angle is stored in. However, that assumes that angle already is an integer and in range of the table. With Math.sin you don't have to deal with that, and calling Math.sin (almost certainly) is faster than mySinTable[ ( ( angle % range ) * precision )|0 ] (and that doesn't even deal with negative values for angle yet). Plus, it's more precise and you can save some time by having a local var mySin = Math.sin. For a table, I'd simply build it at initialisation, if I thought it would be worth it -- but I don't. The penalty of the Math functions is nowhere near as bad as calling a custom method. They're actually pretty fast. Whatever you do with them will take much longer, say, redrawing calculated vectors, hit tests, etc. Better spend your time improving the algorithm you plan to use. Use local vars, avoid function calls. Mark -- http://snafoo.org/ _______________________________________________ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com

