Monday, April 25, 2005

Common AS 1.0 coding mistakes

Using function classname.prototype.methodname() instead of classname.prototype.methodname() = function()

Forgetting to use this when calling an instance method from within the class itself.

Forgetting to convert _xmouse and _ymouse to global coordinate space when doing pixel level hit test. e.g. mc.hitTest(_xmouse, _ymouse, true); // not ok - x and y must be converted to global coordinate space first

Forgetting to use abs when you intend to test for magnitude less than a range
(by forgetting this, any large negative value will pass the test because they are always less than you positive limit)

e.g.

if ((x1 - x2) < 0.005)


Forgetting to introduce epsilon when you perform a floating point comparison

if (fp1 == fp2) // dangerous

instead do

if (abs(fp1 - fp2) < 0.001)


Common JSFL coding mistakes

Forgetting to use fl when you intend to trace (e.g. fl.trace()).

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home