Understanding Macromedia Flash 8 ActionScript 2: Basic Techniques for Creatives

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.
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 is discussed in detail and these terms are explained. For now, the important thing to note is that the constructor function does very little work. The actual drawing of the square happens in a function called:
SimpleSquareAS1.prototype.draw
// Constructor Method<b class="bold">function</b> SimpleSquareAS1 (x:Number, y:Number, size:Number, target:MovieClip) { // Properties coords = <b class="bold">new</b> Object() ; coords.x = x; coords.y = y; this.size = size; movieClipTarget = target; <b class="bold">var</b> depth:Number = movieClipTarget.getNextHighestDepth() ; name = "mySquare_" + depth; mc = movieClipTarget.createEmptyMovieClip(name, depth);<a name="227"></a><a...