Dynamic - MACROMEDIA FLASH MX 2004-ACTIONSCRIPT LANGUAGE Reference

Actionscript language reference
Table of Contents

Advertisement

dynamic

Availability
Flash Player 6.
Usage
dynamic class className
{
// class definition here
}
Note: To use this keyword, you must specify ActionScript 2.0 and Flash Player 6 or later in the Flash
tab of your FLA file's Publish Settings dialog box. This keyword is supported only when used in
external script files, not in scripts written in the Actions panel.
Description
Keyword; specifies that objects based on the specified class can add and access dynamic properties
at runtime.
Type checking on dynamic classes is less strict than type checking on nondynamic classes, because
members accessed inside the class definition and on class instances are not compared with those
defined in the class scope. Class member functions, however, can still be type checked for return
type and parameter types. This behavior is especially useful when you work with MovieClip
objects, because there are many different ways of adding properties and objects to a movie clip
dynamically, such as
MovieClip.createTextField()
Subclasses of dynamic classes are also dynamic.
For more information, see "Creating dynamic classes" in Using ActionScript in Flash.
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]);
}
284
Chapter 2: ActionScript Language Reference
ActionScript Language Reference
[ extends superClass ]
[ implements interfaceName [, interfaceName... ] ]
MovieClip.createEmptyMovieClip()
.
has not yet been marked as dynamic, so calling an
Person2
CHAPTER 2
and

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash mx

Table of Contents