About data types

A data type describes a piece of data and the kinds of operations that you can perform on it. You store data in a variable. You use data types when creating variables, object instances, and function definitions to assign the type of data you're working with. You use many different data types when you write ActionScript.

ActionScript 2.0 defines several commonly used data types. Data types describe the kind of value that a variable or ActionScript element can contain. A variable that is assigned a data type can only hold a value within that data type's set of values. For information on variables, see About variables.

ActionScript has numerous basic data types that you will probably use frequently in your applications. See the table in About primitive and complex data types for more information.

ActionScript also has core classes, such as Array and Date, that are considered complex or reference data types. For more info on complex and reference data types, see About primitive and complex data types. In addition, all data types and classes are fully defined in ActionScript 2.0 Language Reference.

You can also create custom classes for your applications. Any class that you define using the class declaration is also considered a data type. For more information on core and other built-in classes, see About top-level and built-in classes. For more information on creating custom classes, see Classes.

In ActionScript 2.0, you can assign data types to variables when you declare them. The data types you assign can be any of the core types or can represent a custom class that you created. For more information, see About assigning data types and strict data typing.

When you debug scripts, you might need to determine the data type of an expression or variable to understand why it is behaving a certain way. You can do this with the instanceof and typeof operators (see About determining data type).

You can convert one data type to another at runtime using one of the following conversion functions: Array(), Boolean(), Number(), Object(), String().

For a sample of the datatypes.fla file, which shows you how to use data types in an application, see the Flash Samples page at www.adobe.com/go/learn_fl_samples. Download and decompress the Samples zip file and navigate to the ActionScript2.0/DataTypes folder to access the sample.


Flash CS3