Classes

This chapter introduces you to using and writing classes using ActionScript 2.0. Classes are the backbone of ActionScript 2.0, and are more important than they were in earlier versions of Flash. You will learn how important classes are in Flash throughout this chapter.

This chapter begins by explaining some fundamental terminology and how it relates to classes and object-oriented programming (OOP). Next you walk through a sample class file and understand how each section of the class file works and how the class is organized. The rest of the chapter shows you how to create your own custom classes and how to use them within your Flash documents. You learn about the Flash classpath and how a class should be documented so that other people who read or use your code can easily understand the code and the class's overall purpose.

This section contains code examples that you can use to become familiar with creating classes in ActionScript 2.0. By the end of this chapter, you should be able to write a typical class file, understand and recognize Flash classes, and also feel comfortable reading other people's class files.

If you're not familiar with ActionScript 2.0 scripting, see Syntax and Language Fundamentals and Best Practices and Coding Conventions for ActionScript 2.0.

For more information on working with custom and built-in classes, see the following topics:

About object-oriented programming and Flash
Writing custom class files
About working with custom classes in an application
Example: Writing custom classes
Example: Using custom class files in Flash
Assigning a class to symbols in Flash
Compiling and exporting classes
Understanding classes and scope
About top-level and built-in classes
About working with built-in classes

Flash CS3