flash on 2012-3-19

by MMMMMonchi
♥0 | Line 31 | Modified 2012-03-19 13:53:07 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.Sprite;
    import flash.events.Event;
    public class Main extends Sprite {
        public var _ball:Circle;
        public function Main() {
            _ball=new Circle();
            addChild(_ball);
            _ball.addEventListener(Event.ENTER_FRAME,_move);
            
            
        }
      private function _move(e:Event):void{
          _ball.move();
          }
    }
}

import flash.display.Sprite;
class Circle extends Sprite{
      public  var vx:int=10;
      public  var vy:int=10;
   public function Circle(){
       graphics.beginFill(0xff00ff);
       graphics.drawCircle(100,100,10);
       graphics.endFill();
       
       }
   public function move():void{
       
       this.x+=vx;
       this.y+=vy;
       if(this.x<0||this.x>=stage.width)vx=-vx;
       if(this.y<0||this.y>=stage.height)vy=-vy;
       
       }    
    
    
}