Chapter 39 Example 2

by actionscriptbible
♥0 | Line 24 | Modified 2010-02-10 02:45:01 | MIT License
play

ActionScript3 source code

/**
 * Copyright actionscriptbible ( http://wonderfl.net/user/actionscriptbible )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/pX21
 */

package {
  import flash.display.*;
  import flash.events.Event;
  [SWF(frameRate="60")]
  public class ch39ex2 extends Sprite {
    protected var ball:DisplayObject;
    public function ch39ex2() {
      ball = new Ball();
      ball.y = stage.stageHeight/2;
      addChild(ball);
      addEventListener(Event.ENTER_FRAME, onEnterFrame);
    }
    protected function onEnterFrame(event:Event):void {
      ball.x += 0.5;
    }
  }
}
import flash.display.Shape;
class Ball extends Shape {
  public function Ball(color:uint = 0xff0000, size:Number = 50) {
    graphics.beginFill(color);
    graphics.drawCircle(0, 0, size);
  }
}