AS3: Literals
Apr 10th, 2008 by Leo Geis
I really couldn’t get my head around Literals for an unreasonably long time. Simply reading that Literals are values “…that appear directly in the code” really didn’t work for me, and probably won’t for most aerial photographers, who have likely suffered the same number of hypoxic hours at altitude and a few too many high-G turns looking through a 400mm lens…as I have.
ActionScript 3.0 Bible (published by Wiley) helped a lot. It has two separate statements that cleared things up a bit.
The first is on page 9; “…any value that is explicitly included in the code at the time it is compiled.” That’s a great clue, but doesn’t really round out a definition.
The second is on page 155; “…data that can be written directly into the code without using variables, constructors, or othe types of object-oriented structures.”
Now, I still feel the amalgamated definition is still a bit rarified, but that may be my own limitations. At least now I can triangulate what a Literal really, really, really is.
Please remember that Literals can be written directly into the code using Array Access Indicators ( []) and Object Initializer Operators ( {} ). I can understand why these aren’t considered formal OOP structures, and I can understand why they aren’t considered “constructors,” but I’d like to point out that this is a very good example of why capitalizing the formal names of syntactic elements is a good idea to distinguish them from common use terms, because both the Array Access Indicators and Object Initializer Operators are in fact qualified to be described as constructors (lower case “c”). Obviously, Constructors (capital “C”) they are not.
So, Literals are values that are entered explicitly into the code without the use of formal OOP Constructors or Variables, and are present in that form at Compile Time-that is to say that they don’t have to be evaluated to a result at Compile Time.
Is that comfortable?
Of course, I’m not deep enough into AS to rightfully use shorthand, and the fact is that Literals can be difficult to troubleshoot, so I’ll continue to ignore them…just like I do instruction manuals.
L


