ࡱ> Root Entryp|YrRASH @u5 ContentsPage 13Symbol 1   !"#$%&'(Root Entryp|YrRASH{o5ContentsPage 13Symbol 1  )  !"#$%&'()*+,-./012456789:;<=>?@ABCPicPage CPicLayer CPicFrame Hb?@ABt(); } // ======================================== // Create the Ball class. // ======================================== /* * Ball Class. Extends MovieClip. * Version: 1.0.0 * Desc: A movie clip subclass for depicting balls. * * Constructor Params: * radius -The ball's size. * ballColor -The ball's color. * x -The ball's initial x position. * y -The ball's initial y position. * velocity -The ball's movement vector: {x:0, y:0}. * * Methods: * setSize() -Make the ball clip's size match the supplied radius. * setPosition() -Place the ball clip at an (x,y) coordinate. * setColor() -Apply an RGB color value to the ball clip. * move() -Apply the ball's velocity vector to its current position. * * Event Handlers: * onEnterFrame() -Invokes move() every frame. * */ /* * Class Constructor. Parameters are passed by attachMovie()'s initObj. */ org.moock.Ball = function () { // Create Instance properties. this.velocity = this.params.velocity; // Initialize instance. this.setPosition(this.params.x, this.params.y); this.setColor(this.params.ballColor); this.setSize(this.params.radius); this.onEnterFrame = this.move; // Remove constructor params object from the instance. delete this.params; }; /* * Set MovieClip as Ball's superclass. */ org.moock.Ball.prototype = new MovieClip(); /* * Associate the Library's ball symbol with the Ball class. */ Object.registerClass("ballSymbol", org.moock.Ball); /* * Instance Methods */ /* * Method: Ball.setSize() * Desc: Sets the ball clip's size. * * Params: * newRadius -The ball's new radius. * */ org.moock.Ball.prototype.setSize = function (newRadius) { this._width = this._height = (newRadius * 2); }; /* * Method: Ball.setPosition() * Desc: Sets the ball clip's position to the point (x, y). * * Params: * x -The new horizontal position. * y -The new vertical position. */ org.moock.BalCPicPage CPicLayer CPicFrame Hb