EasyManua.ls Logo

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE - Page 204

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
1378 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
204 ActionScript language elements
Subclasses of dynamic classes are also dynamic.
Be sure to specify the type when declaring an object, as in the following:
var x:MyClass = new MyClass();
If you do not specify the type when declaring an object (as in the following) then the object is
considered dynamic:
var x = new MyClass();
Availability: ActionScript 2.0; Flash Player 6
Example
In the following example, class
Person2 has not yet been marked as dynamic, so calling an
undeclared function on it generates an error at compile time:
class Person2 {
var name:String;
var age:Number;
function Person2(param_name:String, param_age:Number) {
trace ("anything");
this.name = param_name;
this.age = param_age;
}
}
In a FLA or AS file that's in the same directory, add the following ActionScript to Frame 1 on
the Timeline:
// Before dynamic is added
var craig:Person2 = new Person2("Craiggers", 32);
for (i in craig) {
trace("craig." + i + " = " + craig[i]);
}
/* output:
craig.age = 32
craig.name = Craiggers */

Table of Contents

Related product manuals