/12/ movie clip subclasses (part 2)

#initclip
// Class
function Ball () {
  this.setColor(this.theColor);
}
Ball.prototype = new MovieClip();
Object.registerClass("ballSymbol", Ball);

// Methods
Ball.prototype.setColor = function (newColor) {
  var ballColor = new Color(this);
  ballColor.setRGB(newColor);
}
Ball.prototype.startMoving = function (moveAmount) {
  this.onEnterFrame = function () {
    this._x += moveAmount;
  }
}
Ball.prototype.stopMoving = function () {
  delete this.onEnterFrame;
}
#endinitclip


// Make an instance. 
this.attachMovie("ballSymbol", "blueBall", 1, { theColor: 0x0000FF });

// Call a method.
this.blueBall.startMoving(5);