O'Reilly logo

Essential ActionScript 3.0 by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Untyped Variables, Parameters, Return Values, and Expressions

A variable or parameter whose definition includes a type annotation is said to be a typed variable or typed parameter. Likewise, a function definition that includes a return-type annotation is said to have a typed return value. Furthermore, an expression that refers to a typed variable or a typed parameter, or calls a function with typed return value is known as a typed expression.

Conversely, a variable or parameter whose definition does not include a type annotation is said to be an untyped variable or untyped parameter. Likewise, a function definition that does not include a return-type annotation is said to have an untyped return value. An expression that refers to an untyped variable or an untyped parameter, or calls a function with an untyped return value is known as a untyped expression.

Untyped variables, parameters, and return values are not constrained to a specific datatype (as typed variables, parameters, and return values are). For example, an untyped variable can be assigned a Boolean value on one line, and a VirtualPet object on another without error:

var stuff = true;
stuff = new VirtualPet("Edwin");  // No error

Tip

ActionScript does not generate type-mismatch errors for untyped variables, parameters, and return values.

Programmers wishing to explicitly indicate that a variable, parameter, or return value is intentionally untyped can use the special type annotation, :*. For example, the following code defines ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required