Adobe FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manual page 38

Migrating applications to flex 2
Table of Contents

Advertisement

Constants
You can use the
keyword to define constants in ActionScript 3.0. First, you determine
const
which class and instance variables qualify as constants, and then declare them with
const
instead of
; for example:
var
static const NONMODAL:Number = Alert.NONMODAL;
const backgroundColorName:String = "buttonColor";
In general, constants should be class constants rather than instance constants.
The initial value for a constant must be an expression that can be evaluated at compile time.
Also, you cannot create constants of type Array or Object.
Method signatures
This section describes changes to method signatures in ActionScript 3.0.
No arguments
If a function takes no arguments, be sure to specify its argument list as
and not as
.
()
(void)
The latter specifies a single argument of type Object named "void". Consider which, if any, of
the arguments should be optional, and assign default values for them; for example:
override public function createClassObject(type:Class, name:String=null,
depth:int=0, initObj:Object=null):UIObject
Variable number of arguments
If the function takes a variable number of arguments, use the new "..." syntax:
function function_name([ arguments ], ... arrayOfArgs)
For example:
function foo(n:Number, ... arrayOfArgs):void
The "
" and its array must be the last argument in the method. You cannot specify a type
...
because it is always an Array containing the other arguments.
The following example shows how to use a method with a variable number of arguments. If
you define the following:
function myfunc(arg1, ... arrayOfArgs)
you can call it as:
myfunc(a, b, c, d);
and the Array arrayOfArgs will have the value
.
[ b, c, d ]
38
ActionScript 2.0 to 3.0

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex 2

Table of Contents