flash on 2009-7-27
---------------------------------------------------------------------------------------------
標準ライブラリ
---------------------------------------------------------------------------------------------
package {
/*---------------------------------------------------------------------------------------------*/
//標準ライブラリ
import flash.display.*;
import flash.events.*;
/*---------------------------------------------------------------------------------------------*/
public class Main extends Sprite {
private var sin:Array = [];
/*-------------------------------------------------------------------------------------*/
public function Main() {
//ステージの設定
stage.align = StageAlign.TOP_LEFT;
stage.quality = StageQuality.HIGH;
stage.scaleMode = StageScaleMode.NO_SCALE;
//set event listener added to stage
this.addEventListener(Event.ADDED_TO_STAGE, initialize);
} /* constructor */
/*-------------------------------------------------------------------------------------*/
private function initialize(event:Event):void {
//イベントリスナの消去
this.removeEventListener(Event.ADDED_TO_STAGE, initialize);
//
var sprite:Sprite = new Sprite();
this.addChild(sprite);
//変数の定義
var i:int = 0;
var x:Number = 0;
var y:Number = 0;
var r:Number = 0;
var z:Number = 0;
//sinの値を配列に格納
var sin:Array = new Array();
for (i=0; i<72; i++) {
sin[i] = 40 * Math.sin(i * Math.PI / 36);
} /* for */
this.addEventListener(Event.ENTER_FRAME, function():void {
sprite.graphics.clear();
sprite.graphics.lineStyle(0, 0x000000, 100);
for (x=i=0; i < 73; i++) {
sprite.graphics.moveTo(x, 100 + y);
x += 20;
if ((z=i+r)>71) {
z -= 72;
if (z>71) {
z = 0;
}
}
y = sin[z];
sprite.graphics.lineTo(x, 100 + y);
}
(r++==72) && (r=0);
});
} /* function initialized */
/*-------------------------------------------------------------------------------------*/
} /* class Main */
/*---------------------------------------------------------------------------------------------*/
} /* package */