
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
44
|
Chapter 3: Datatypes and Type Checking
Some languages (e.g., Java) address the need for multiple parameter
types with so-called method overloading. Method overloading lets mul-
tiple methods have the same name but define unique parameter types.
When an overloaded method is called, the compiler determines which
version of the method to execute based on the datatype(s) of the
passed argument(s). ActionScript 2.0 does not support method over-
loading. However, we’ll see how to simulate overloaded methods and
constructor functions in Chapter 4.
Allowing Property and Method Creation
on a Class’s Instances
As of the introduction of ActionScript 2.0, the compiler normally generates an error
when you attempt to access a nonexistent property or method on an object. (A non-
existent property or method is one that is not defined by the object’s class.) If, how-
ever, you feel you must create a class that allows new properties or methods to be
added to its instances at runtime, you can disable nonexistent property and method
checking by declaring the class dynamic. For much more information, see “Class
Attributes” in Chapter 4.
Do not take this technique lightly. Dynamic classes let you create instances that have
unknown properties and methods, which can cause unexpected results in the rest of