forked from: BitmapDataとMath.sin(), Math.cos()

by wwbeyondww1 forked from BitmapDataとMath.sin(), Math.cos() (diff: 1)
♥0 | Line 27 | Modified 2013-07-30 11:15:44 | MIT License
play

ActionScript3 source code

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

// forked from geko's BitmapDataとMath.sin(), Math.cos()
// BitmapDataとMath.sin(),Math.cos()でグラフを描こう
// 画面クリックで描画/非描画の切替え

package {
    import flash.display.*;
    import flash.events.*;
    
    public class FlashTest extends Sprite {
        
        public function FlashTest() {
            var bmd:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight);
            var shape:Shape = new Shape();
            var i:Number = 0;
            var draw:Boolean = true;
            shape.graphics.beginFill(0xDD9900);
            shape.graphics.drawCircle(0, 0, 3);
            shape.graphics.endFill();
            addChild(new Bitmap(bmd));
            addChild(shape);
            
            addEventListener(Event.ENTER_FRAME, function loop(event:Event):void{
                shape.x = stage.stageWidth/2;// + Math.cos(Math.PI/2*i)*100;
                shape.y = stage.stageHeight/2 + Math.sin(Math.PI/2*i)*100;
                bmd.scroll(-2,0);
                if(draw) bmd.draw(stage);
                i += 0.05;
            });
            stage.addEventListener(MouseEvent.CLICK, function click(event:MouseEvent):void{
                draw = !draw;
            });
        }
    }
}