In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

spiral

螺旋作ってみました。

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

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 Spiral extends Sprite{
        private var mc:Sprite;
        private var timer:Timer=new Timer(250);
        private var mc_array:Array=new Array();

        public function Spiral() {
            
            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].rotationY-=4.5;
                if(mc_array[i].y>stage.stageHeight){
                    removeChild(mc_array[i]);
                    var remove_mc:Array=mc_array.splice(i,1);
                }
                if(mc_array[i].x>=225&&mc_array[i].x<325&&mc_array[i].z<200&&mc_array[i].z>=0){
                    mc_array[i].x+=5;
                    mc_array[i].z+=10;
                }else if(mc_array[i].x>225&&mc_array[i].x<=325&&mc_array[i].z>=200&&mc_array[i].z<800){
                    mc_array[i].x-=5;
                    mc_array[i].z+=10;
                }else if(mc_array[i].x<=225&&mc_array[i].x>125&&mc_array[i].z>200&&mc_array[i].z<=800){
                    mc_array[i].x-=5;
                    mc_array[i].z-=10;
                }else if(mc_array[i].x<225&&mc_array[i].x>=125&&mc_array[i].z<=200&&mc_array[i].z>0){
                    mc_array[i].x+=5;
                    mc_array[i].z-=10;
                }
                
                
            }
        }
        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=225;
            
            mc_array.push(mc);
            mc_array[mc_array.length-1].x=225;
            mc_array[mc_array.length-1].y=0;        
            addChild(mc_array[mc_array.length-1]);
        }

    }
    
}