forked from: flash on 2010-2-18
forked from flash on 2010-2-18 (diff: 5)
円運動
ActionScript3 source code
/**
* Copyright e2o ( http://wonderfl.net/user/e2o )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/QPuL
*/
// forked from tan_go238's flash on 2010-2-18
/*
* 円運動
*/
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.utils.Timer;
public class FlashTest extends Sprite {
/*********** CONSTANTS ***********/
private const stageWidth:int = stage.stageWidth;
private const stageHeight:int = stage.stageHeight;
private const centerX:int = stageWidth / 2;
private const centerY:int = stageHeight / 2;
private const radius:Number = 30;
/*********** VARIABLES ***********/
private var particles:Array = new Array;
private var degree:int = 0;
private var posX:int = stageWidth - radius;
private var posY:int = stageHeight - radius;
private var particle:Particle = new Particle();
private var timer:Timer;
public function FlashTest() {
addEventListener( Event.ADDED_TO_STAGE, init );
}
/*********** FUNCTIONS ***********/
private function init(e:Event):void
{
removeEventListener( Event.ADDED_TO_STAGE, init );
particle.x = stageWidth / 2;
particle.y = stageHeight / 2;
addChild(particle);
//addEventListener(Event.ENTER_FRAME, loop);
timer = new Timer(30, 0);
timer.addEventListener(TimerEvent.TIMER,loop);
timer.start();
}
private function loop(e:TimerEvent):void
{
var radian:Number = Math.PI/180*degree;
posX = particle.x;
particle.x = centerX + radius * Math.cos(radian);
particle.y = centerY + radius * Math.sin(radian);
degree += 10;
}
}
}
import flash.display.Sprite;
class Particle extends Sprite
{
public function Particle()
{
graphics.beginFill(0xf13);
graphics.drawCircle(0, 0, 10);
graphics.endFill();
}
}
