Understanding Macromedia Flash 8 ActionScript 2: Basic Techniques for Creatives

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.
<b class="bold">class</b> ch6.SimpleSquare { // Properties <b class="bold">public var</b> coords:Object; <b class="bold">public var</b> name:String; <b class="bold">public var</b> size:Number; <b class="bold">public var</b> mc:MovieClip; <b class="bold">public var</b> movieClipTarget:MovieClip; // Constructor Method <b class="bold">public function</b> SimpleSquare(x:Number, y:Number, size: Number, target:MovieClip) { 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); mc._x = coords.x; mc._y = coords.y; }<a name="249"></a><a name="N9032"></a> //draw method <b class="bold">public...