I guess I hadn’t thought too deeply about it, but I always thought that the ‘as’ Operator was the equivalent of typing a variable.
pseudo code example:
type(test) = test as type
or to give a real world example:
var myVar:String=’3′; var myInt:int=int(myVar);
var myInt2:int=myVar as int; trace(myInt,myInt2);
But this code will trace:
I’ve realised that while typing a variable actually converts the variable to the requested datatype, ‘as’ merely informs the compiler to expect a certain variable to be of a certain datatype.
In the above example, ‘myString as int’ doesn’t work because myString isn’t an int.
However, if initially we had defined myVar like so:
The code would have no problem as myVar is an int.