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

赤の習作1

Get Adobe Flash player
by chieinoue 24 Feb 2010
    Embed
/**
 * Copyright chieinoue ( http://wonderfl.net/user/chieinoue )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/yxcE
 */

package {
    import flash.display.DisplayObject;
    import flash.display.Graphics;
    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.events.*;
    import com.flashdynamix.motion.*;
    import flash.text.TextField; 
       
    public class FlashTest extends Sprite {
    	
    	    private var _cnt:int = 0;
    	    private var _y:Number = 0;
        private var tf:TextField;
        private var base:Sprite;
    	
        public function FlashTest() {
            tf = new TextField();
            tf.autoSize = 'left';
            tf.multiline = true;
            tf.width = 200;
            tf.height = 300;
            addChild(tf);
            
            init();
        }
        
        private function init():void{      
		    base = new Sprite();
            base.graphics.beginFill(0xFFFFFF);
            base.graphics.drawRect(0, 0, 500, 500);
            base.graphics.endFill();
            addChild(base);
                    	    
			_y = 500;
			_cnt = 0;
            addEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
        }
        
        private function onEnterFrameHandler(event:Event):void{
            _cnt++;
            if(_cnt%30 == 0){
				var red:uint = 0x0000FF << 16;
				var green:uint = (Math.random()*0x000066) << 8;
				var blue:uint = Math.random()*0x0000CC;
				        	
	            var child:Shape = new Shape();
	            child.graphics.beginFill(red+green+blue);
	            child.graphics.drawRect(0, 0, 500, 10+Math.floor(Math.random()*40));
	            child.graphics.endFill();
                if(_cnt%60 == 0){
            	        child.x = child.width * -1;
                }else{
            	        child.x = child.width * 2;
                }
	            _y -= child.height;
	            child.y = _y;
	            base.addChild(child);
				var tween:TweensyTimeline = Tweensy.to(child, {x:0}, 0.5);

				if(_y < -50){
                     removeEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
					removeChild(base);
					init();
				}
	        }
        }
    }
}