298
Classes
About calling built-in object methods
You call an object’s method by using the dot (
.
) operator followed by the method. For
example, the following code creates a new Sound object and calls its
setVolume()
method:
var my_sound:Sound = new Sound(this);
my_sound.setVolume(50);
For examples of working with methods of the built-in MovieClip class, see
Chapter 11,
“Working with Movie Clips,” on page 351
. For examples of working with methods of the
built-in TextField, String, TextRenderer, and TextFormat classes, see
Chapter 12, “Working
with Text and Strings,” on page 381
.
About class (static) members
Some built-in ActionScript classes have
class members
(
static members
).
Class members
(properties and methods) are accessed or invoked on the class name, not on an instance of the
class. Therefore, you don’t create an instance of the class to use those properties and methods.
For example, all the properties of the Math class are static. The following code invokes the
max()
method of the Math class to determine the larger of two numbers:
var largerNumber:Number = Math.max(10, 20);
trace(largerNumber); // 20
For more information on static methods of the Math class, and examples of using them, see
Math in the
ActionScript 2.0 Language Reference
.
Excluding classes
To reduce the size of a SWF file, you might want to exclude classes from compilation but still
be able to access and use them for type checking. For example, you might want to do this if
you are developing an application that uses multiple SWF files or shared libraries, especially
those that access many of the same classes. Excluding classes helps you avoid duplicating
classes in those files.
For more information on excluding classes, see the following topics:
■
“Preloading class files” on page 299
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...