View Full Version : Event.EVENT vs. "event"
bodyvisual
December 27th, 2006, 06:33 AM
so i've just started messing around with as3, and am wondering what the pros/cons of these two methods are.
for example,
ActionScript Code:
stage.align = "tl";
vs
ActionScript Code:
import flash.display.StageAlign;
...
stage.align = StageAlign.TOP_LEFT;
or
ActionScript Code:
stage.addEventListener(Event.RESIZE, stage_resize);
// vs
stage.addEventListener("resize", stage_resize);
know what i mean?
devonair
December 27th, 2006, 07:38 AM
The static contants are for error checking/troubleshooting purposes. For example if you type in stage.align = "tl"; (as you did in your post), the application will fail silently (it should be "TL", not "tl") and can cost a lot in wasted time in tracking down errors. But if you accidentally type stage.align = StageAlign.TOP_LIFT; (instead of TOP_LEFT), you'll immediately get an error message and can fix the problem and move on..
bodyvisual
December 27th, 2006, 01:25 PM
ah ha, makes perfect sense. thanks!
TheCanadian
December 27th, 2006, 02:07 PM
Although it should be noted that those methods will except any mix of cases in the string assigned to them since they call String.toLowerCase on the passed string.
For example, all of the following will change the quality of the movie to low:
stage.quality = StageQuality.LOW;
stage.quality = "low";
stage.quality = "LOW";
stage.quality = "lOw";
Krilnon
December 27th, 2006, 07:11 PM
Also, the values of the constants might change later (unlikely for the flash package's classes), but whoever designed the class probably wouldn't change the constant's identifier.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.