155
CHAPTER 9
Creating Classes with ActionScript 2.0
ActionScript 2.0 is a restructuring of the ActionScript language that provides several powerful
new programming features found in other programming languages, such as Java. ActionScript 2.0
encourages program structures that are reusable, scalable, robust, and maintainable. It also
decreases development time by providing users with thorough coding assistance and debugging
information. ActionScript 2.0 conforms to existing standards and is based on the ECMAScript 4
proposal (
www.mozilla.org/js/language/es4/
). ActionScript 2.0 is available in Macromedia Flash
MX 2004 and Macromedia Flash MX Professional 2004.
The features of ActionScript 2.0 are described below.
Familiar object-oriented programming (OOP) model
The primary feature of
ActionScript 2.0 is a familiar model for creating object-oriented programs. ActionScript 2.0
introduces several new object-oriented concepts and keywords such as
class
,
interface
, and
packages
that will be familiar to you if you’ve ever programmed with Java.
The OOP model provided by ActionScript 2.0 is a “syntactic formalization” of the prototype
chaining method used in previous versions of Macromedia Flash to create objects and
establish inheritance.
Strict data typing
ActionScript 2.0 also lets you explicitly specify data types for variables,
function parameters, and function return types. For example, the following code declares a
variable named
userName
of type String (a built-in ActionScript data type, or class).
var userName:String = "";
Compiler warnings and errors
The above two features enable the authoring tool and compiler
to provide compiler warnings and error messages that help you find bugs in your applications
faster than was previously possible in Flash.
Caution:
If you plan to use ActionScript 2.0 syntax, ensure that the Publish settings for the FLA file
specify ActionScript 2.0. This is the default for files created in Flash MX 2004. However, if you open
an older FLA file that uses ActionScript 1 and begin rewriting it in ActionScript 2.0, change the
Publish Settings of the FLA file to ActionScript 2.0. If you don’t do so, your FLA file will not compile
correctly, but no errors will be generated.
Summary of Contents for FLASH MX 2004 - ACTIONSCRIPT
Page 1: ...ActionScript Reference Guide...
Page 8: ...8 Contents...
Page 12: ......
Page 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Page 54: ...54 Chapter 2 ActionScript Basics...
Page 80: ...80 Chapter 3 Writing and Debugging Scripts...
Page 82: ......
Page 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Page 112: ......
Page 120: ...120 Chapter 6 Using the Built In Classes...
Page 176: ......
Page 192: ...192 Chapter 10 Working with External Data...
Page 202: ...202 Chapter 11 Working with External Media...
Page 204: ......
Page 782: ...782 Chapter 12 ActionScript Dictionary...
Page 793: ...Other keys 793 221 222 Key Key code...
Page 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Page 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Page 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Page 816: ...816 Index...