MACROMEDIA FLASHLITE2 ACTIONSCRIPT-LANGUAGE Reference page 191

Actionscript language reference
Table of Contents

Advertisement

Example
In the following example, class
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 */
If you add an undeclared function,
example:
trace("");
craig.dance = true;
for (i in craig) {
trace("craig." + i + " = " + craig[i]);
}
/* output: **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 14: There is
no property with the name 'dance'. craig.dance = true; Total ActionScript
Errors: 1 Reported Errors: 1 */
Add the
keyword to the Person2 class, so that the first line appears as follows:
dynamic
dynamic class Person2 {
Test the code again, and you see the following output:
craig.dance = true craig.age = 32 craig.name = Craiggers
See also
class statement
has not yet been marked as dynamic, so calling an
Person2
, an error is generated, as shown in the following
dance
Statements
191

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash lite 2

Table of Contents