Spiral ver.2

by snaf
前回の螺旋がカクカクだったので方法を変更しました。
♥0 | Line 42 | Modified 2011-10-18 15:34:08 | MIT License
play

ActionScript3 source code

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

package  {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.display.*;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    
    public class Spiral2 extends Sprite{
        private var mc:Sprite;
        private var timer:Timer=new Timer(125);
        private var mc_array:Array=new Array();
        private var angle:Number = 0;   
        private var hankei:Number = 100;  

        public function Spiral2() {            
            addEventListener(Event.ENTER_FRAME,xEnterframe);
            timer.addEventListener(TimerEvent.TIMER,getMcEvent);
            timer.start();
            
        }
        private function xEnterframe(e:Event):void{
            for(var i:int=0;i<mc_array.length;i++){
                mc_array[i].y+=1;
                mc_array[i].x = stage.stageWidth/2 + hankei * Math.cos(angle * Math.PI * 2+i);   
                mc_array[i].z = stage.stageHeight / 2 + hankei * Math.sin(angle * Math.PI * 2+i);  
                mc_array[i].rotationY= -Math.cos(angle * Math.PI * 2+i)*180/Math.PI;
                /*if(mc_array[i].y>stage.stageHeight){
                    removeChild(mc_array[i]);
                    mc_array.splice(i,1);
                }*/
            }
            angle += 0.006;      
        }
        private function getMcEvent(e:TimerEvent):void{
            mc= new Sprite();  
            mc.graphics.beginFill(0);
            mc.graphics.drawRect(0,0,25,15);
            mc.graphics.endFill();
            addChild(mc);   
            mc.x = stage.stageWidth / 2;   
            mc.y = 0;   
            
            mc_array.push(mc);
            mc_array[mc_array.length-1].x=stage.stageWidth / 2;  
            mc_array[mc_array.length-1].y=-100;      
            addChild(mc_array[mc_array.length-1]);
        }
    }
}