Sine wave
♥0 |
Line 33 |
Modified 2011-04-02 23:06:21 |
MIT License
archived:2017-03-09 21:57:17
ActionScript3 source code
/**
* Copyright Tosakun.Meeting ( http://wonderfl.net/user/Tosakun.Meeting )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/piB8
*/
package{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.utils.Timer;
public class SineWaveMoving extends Sprite{
private var _xRadius:Number = 100; /**** ****/
private var _angle:Number=45; /**** degree ****/
private var _yRadius:Number=150;
private var _speed:Number=10;
public function SineWaveMoving(){
this.drawMe();
this.setPosition(0,400);
var timer:Timer = new Timer(50,0);
timer.addEventListener("timer",moveMe);
timer.start();
}
public function setPosition(x:Number,y:Number):void{
this.x=x;
this.y=y;
}
private function drawMe():void{
/**** to draw a red circle with 50 pixels radias ****/
this.graphics.beginFill(0xFF0000,200);
this.graphics.drawCircle(0,0,10);
this.graphics.endFill();
}
private function moveMe(e:TimerEvent):void{
this.y=200+Math.sin(_angle)*_yRadius;
//this.y=200+Math.sin(_angle)*_yRadius;
this.x+=_speed;
this._angle+=0.5;
}
}
}