Casting
When you pass references among objects to that of a generalized type, you often have to cast an object back into its actual data type. There are two ways to cast an object in ActionScript 3.0: the cast operation, which wraps an expression such as Type( expression ), and the as operator ( expression as DataType ). Both approaches have distinct advantages over the other, such as readability, conversion precedence, and casting failures.
Typically, in ActionScript 3.0, you use the as operator to properly cast an object into another data type. Why? Because, unfortunately, too many developers mimic behavior presented to they learned the language. This is due to three reasons.
First, not every cast works properly when used as a wrapped expression. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access