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

Graphic of Sin

Get Adobe Flash player
by aj.h 05 Jun 2013

    Talk

    J.J at 05 Jun 2013 20:55
    y = -Math.sin(x)*Math.exp(x*dist)
    Embed
package {
    import flash.geom.Point;
    import flash.display.Sprite;
    
    public class FlashTest extends Sprite {
    
        private var amplitude:Number = 0.5;
        private var frequency:uint = 10;
        private var halfStageWidth:Number = 0;
        
        public function FlashTest():void {
            halfStageWidth = stage.stageWidth * 0.5;  
        
            this.graphics.lineStyle(1,0xffffff,0.2);
            this.graphics.beginFill(0x000000);
            this.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
            this.graphics.endFill();
            
            this.graphics.moveTo(0, stage.stageHeight * 0.5);    
            this.graphics.lineTo(stage.stageWidth,stage.stageHeight * 0.5);
            
            this.graphics.moveTo(stage.stageWidth * 0.5 , 0);    
            this.graphics.lineTo(stage.stageWidth*0.5 , stage.stageHeight);
            
            var startPoint:Point = new Point(stage.stageWidth * 0.5 ,stage.stageHeight * 0.5);
            
            this.graphics.lineStyle(1,0xffffff,1);
            this.graphics.moveTo(startPoint.x,startPoint.y);
            
            for(var iter:Number = 0 ; iter < halfStageWidth; iter++){
                var destPoint:Point = new Point(startPoint.x + iter ,startPoint.y + (halfStageWidth - iter) * amplitude * Math.sin(iter / frequency));
                this.graphics.lineTo(destPoint.x, destPoint.y);
            }
        }
    }
}