flash on 2010-11-20
♥0 |
Line 36 |
Modified 2010-11-20 02:44:00 |
MIT License
archived:2017-03-20 15:38:30
ActionScript3 source code
/**
* Copyright majoraze ( http://wonderfl.net/user/majoraze )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/hZqR
*/
package {
import flash.display.Sprite;
import flash.events.Event;
public class Teste extends Sprite {
private var ball:Ball;
private var angle:Number = 0;
public function Teste() {
init();
}
private function init():void {
ball = new Ball();
addChild(ball);
ball.x = stage.stageWidth / 2;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(e:Event):void {
ball.y = stage.stageHeight / 2 + Math.sin(angle) * 50;
angle += .1;
}
}
}
//ball class
import flash.display.Sprite;
class Ball extends Sprite {
private var radius:Number;
private var color:uint;
public function Ball(radius:Number = 40, color:uint = 0xff0000) {
this.radius = radius;
this.color = color;
init();
}
public function init():void {
graphics.beginFill(color);
graphics.drawCircle(0,0,radius);
graphics.endFill()
}
}