What exactly does var x:* mean in actionscript?

actionscript

Solution

Expanding on the other answers, declaring something with type asterisk is exactly the same as leaving it untyped.

var x:* = {};
var y = {}; // equivalent

However, the question of whether you are allowed to assign non-existant properties to objects has nothing to do with the type of the reference, and is determined by whether or not the object is an instance of a dynamic class.

For example, since Object is dynamic and String is not:

var o:Object = {};
o.foo = 1; // fine
var a:* = o;
a.bar = 1; // again, fine

var s:String = "";
s.foo = 1; // compile-time error
var b:* = s;
b.bar = 1; // run-time error

Note how you can always assign new properties to the object, regardless of what kind of reference you use. Likewise, you can never assign new properties to the String, but if you use a typed reference then this will be caught by the compiler, and with an untyped reference the compiler doesn't know whether `b` is dynamic or not, so the error occurs at runtime.

Incidentally, doc reference on type-asterisk can be found here:

http://livedocs.adobe.com/labs/air/1/aslr/specialTypes.html#*

(The markup engine refuses to linkify that, because of the asterisk.)

Problem

Its a little tricky to search for 'var:*' because most search engines wont find it. I'm not clear exactly what var:* means, compared to say var:Object I thought it would let me set arbitrary properties on an object like : ``` var x:* = myObject; x.nonExistantProperty = "123"; ``` but this gives me an error : ``` Property nonExistantProperty not found on x ``` What does * mean exactly? Edit: I fixed the original var:* to the correct var x:*. Lost my internet connection

Original source