6Transitioning from AS1 Classes to AS2 Classes

Classes in ActionScript 1

In ActionScript 1, it was possible to define and use classes. The code was awkward but it worked well and allowed for a dramatic improvement in the organization of application code. For anyone who mastered ActionScript 1 classes, the transition to ActionScript 2 will be easy.

The SimpleSquareAS1 Class

Listing 6.1 shows a class definition — in ActionScript 1 style — for a class called SimpleSquareAS1. It is based on the mySquare( ) function from Chapter 5. The initial function definition — SimpleSquareAS1 — serves as the main class definition and the “constructor”. It initializes the variables which will serve as the class's “properties”. In Chapter 7, the anatomy of a class ...

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.