forked from: flash on 2010-9-29

by mtkythr
♥0 | Line 23 | Modified 2010-09-29 21:15:11 | MIT License
play

ActionScript3 source code

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

// forked from imast's flash on 2010-9-29
package {
    import flash.display.Sprite;
    import flash.events.Event;
    
    public class RandomLine extends Sprite {
        
        private var count:int = 0;
        
        public function RandomLine() {
            this.graphics.lineStyle( 1, 0xFF358B );
            this.graphics.moveTo( this.stage.stageWidth / 2, this.stage.stageHeight / 2 );
            
            this.addEventListener( Event.ENTER_FRAME, enterFrameHandler );
        }
        
        private function enterFrameHandler( event:Event ):void {
            if( count < 2000 ){
                
                var xx:int = Math.random() * this.stage.stageWidth;
                var yy:int = Math.random() * this.stage.stageHeight;
                
                this.graphics.lineTo( xx, yy );
                count++;
            }
            else{
                this.removeEventListener( Event.ENTER_FRAME, enterFrameHandler );
            }
        }
    }
}