Actionscript:
-
const HALF_PI:Number = Math.PI / 2;
-
const RADS:Number = Math.PI / 180;
-
-
trace(HALF_PI);
-
// convert degrees to radians
-
trace(180 * RADS);
When I have constant values I often forget to go ahead and make use of the const keyword. I used to do this a good deal when AS3 first came out.... not sure why I stopped doing it. Anyway, hopefully this post will help remind me to use them...
A very common use for them is of course defining event types:
Actionscript:
-
// inside a class
-
public static const RENDER_COMPLETE:String = "renderComplete";