Assigning Data Types To Elements - MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

Several methods and functions return
demonstrates how you can use
if (Selection.getFocus() == null) {
trace("no selection");
}
Undefined data type
The undefined data type has one value,
which a value hasn't been assigned, either by your code or user interaction.
The value
undefined
variable or property. You use the undefined data type to check if a variable is set or defined. This
data type lets you write code that executes only when the application is running, as shown in the
following example:
if (init == undefined) {
trace("initializing app");
init = true;
}
If your application has multiple frames, the code does not execute a second time because the
variable is no longer undefined.
Void data type
The void data type has one value,
function does not return a value, as shown in the following example:
//Creates a function with a return type Void
function displayFromURL(url:String):Void

Assigning data types to elements

At runtime, Flash Player automatically assigns data types to the following kinds of language
elements, as discussed in the next section:
Variables
Parameters passed to a function, method, or class
Values returned from a function or method
Objects created as subclasses of existing classes
In ActionScript 2.0, you should explicitly assign data types to items, which can help prevent or
diagnose certain errors in your scripts at compile time and offers other benefits. This technique is
called strict data typing.
For more information on assigning data types, see the following topics:
"Automatic data typing" on page 24
"Strict data typing" on page 24
if no value has been set. The following example
null
to test if form fields currently have form focus:
null
undefined
is automatically assigned; unlike
, and is used in a function definition to indicate that the
void
, and is automatically assigned to a variable to
, you don't assign
null
Assigning data types to elements
to a
undefined
init
23

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flex

Table of Contents