7 The Anatomy of a Class

The SimpleSquare class from Chapter 6 is a very simple example of a class, but it has all of the most important elements. Like all classes it exists in an external file, which in this case is called, “SimpleSquare.as”. More importantly, it has the necessary structure that allows Flash to know what to do with it. Every class has at least the following elements:

  • A class declaration.
  • A number of property declarations.
  • A constructor method declaration.
  • A number of method declarations.

These elements can be seen in Listing 7.1.

Listing 7.1

image

Declarations

The first thing you will notice is the class declaration:

class ch6.SimpleSquare ...

Get Understanding Macromedia Flash 8 ActionScript 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.