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

Electricity Lines

package {
    import flash.display.Sprite;
    import flash.display.StageScaleMode;
    import flash.display.StageAlign;
    import flash.events.Event;
    import flash.filters.GlowFilter;
    
    [SWF(width="60",height="60",frameRate="12")]
    public class FlashTest extends Sprite {
        
        private var lines_sp:Sprite = new Sprite();
        private var numLines:Number = 30;
        private var chaosIntensity:Number = 50;
        private var elementColor:uint = 0x22D3FF;
        private var glowFilter:GlowFilter = new GlowFilter(elementColor,1,30,1,2);
        
        public function FlashTest() {
            // write as3 code here..
            init();
        }
        
        public function init():void
        {
            //stage
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            
            //lines
            addChild(lines_sp);
            refreshLines();
            
            //lines glow
            lines_sp.filters = [glowFilter]
            
            //EnterFrame Listener
            stage.addEventListener(Event.ENTER_FRAME , onEnterFrameFunc);
            
        }
        
        private function refreshLines():void
        {
            var posX:Number = stage.stageWidth / numLines;
            
            lines_sp.graphics.clear();
            lines_sp.graphics.lineStyle(2,elementColor);
            lines_sp.graphics.moveTo(  0 , stage.stageHeight * 0.5 );
                
            for(var i:int=0; i<numLines; i++)
            {
                lines_sp.graphics.lineTo( posX * i , (( Math.random() * chaosIntensity) + stage.stageHeight * 0.5 - chaosIntensity * 0.5 ));
            }
            lines_sp.graphics.lineTo( stage.stageWidth  , stage.stageHeight * 0.5); 
        }
        
        private function onEnterFrameFunc(e:Event):void
        {
            refreshLines();
        }
    }
}