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

forked from: ShimmeryText and filters - 陽炎

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

// forked from tjoen's ShimmeryText and filters - 陽炎
// forked from tjoen's forked from: ShimmeryText - 陽炎
// forked from cpu_t's ShimmeryText - 陽炎
package
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.filters.*;
    import flash.geom.ColorTransform;
    import flash.geom.Matrix;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import com.greensock.*;
    import com.greensock.easing.*;

    [SWF(frameRate=100)]
    
    public class FlashTest extends Sprite
    {
        private var SW:Number;
        private var SH:Number;
        private var displasementFilter:DisplacementMapFilter;
        
        private var canvas:BitmapData;
        private var bdSrc:BitmapData;
        
        private var ctrans:ColorTransform;
        
        public function FlashTest()
        {
            SW=stage.stageWidth;
            SH=stage.stageHeight;
            
            this.graphics.beginFill(0);
            this.graphics.drawRect(0,0,SW,SH);
            TweenMax.to(this, 0, {blurFilter:{blurX:5, blurY:5, quality:1}});
            canvas=new BitmapData(SW,SH,false,0);
            var bddis:BitmapData=canvas.clone();
            bddis.perlinNoise(SW/2,SH/2,2,Math.random()*0xFFFFFFFF,true,true,3|6);
            displasementFilter=new DisplacementMapFilter(bddis,null,2,4,80,80,"clamp");
            
            var tf:TextField=new TextField();
            tf.defaultTextFormat=new TextFormat("Verdana",58,Math.random()*0xffffff,true);
            tf.text="BradSedito.";
            tf.autoSize="left";
            
            var myGlow:GlowFilter = new GlowFilter();
            var myBlur:BlurFilter = new BlurFilter();
            var myBevel:BevelFilter = new BevelFilter();
            myBevel.type = BitmapFilterType.FULL;
            myBevel.distance = 4;
            myBevel.highlightColor = 0xFF0000;
            myBevel.shadowColor = Math.random()*0xffffff;
            myBevel.blurX = 10;
            myBevel.blurY = 10;
            myGlow.alpha=0.6;
            myGlow.inner= false; 
            myGlow.color = 0x66FF00; 
            myGlow.blurX = 2; 
            myGlow.blurY = 2; 
            myBlur.quality = 4;
            myBlur.blurX = 2;
            myBlur.blurY = 2;
            tf.filters=[myGlow, myBevel] //add myBlur if you want
            addChild(tf);
            
            var mat:Matrix=new Matrix();
            mat.translate(SW/2-tf.width/2,SH/2-tf.height/2);
            
            bdSrc=canvas.clone();
            bdSrc.draw(tf,mat);
            
            canvas.applyFilter(bdSrc,bdSrc.rect,bdSrc.rect.topLeft,displasementFilter);
            
            addChild(new Bitmap(canvas));
            
            //ctrans=new ColorTransform(0.95,0.92,0.9);
            ctrans=new ColorTransform(0.9,0.92,0.9);
            addEventListener(Event.ENTER_FRAME,enterFrameHandler);
        }
        
        private var scrollPixels:int=3;
        private function enterFrameHandler(e:Event):void
        {
            var temp:BitmapData=new BitmapData(SW,scrollPixels);
            temp.copyPixels(displasementFilter.mapBitmap,temp.rect,temp.rect.topLeft);
            displasementFilter.mapBitmap.scroll(0,-scrollPixels);
            displasementFilter.mapBitmap.copyPixels(temp,temp.rect,new Point(0,SH-scrollPixels));
            
            temp=canvas.clone();
            temp.applyFilter(bdSrc,bdSrc.rect,bdSrc.rect.topLeft,displasementFilter);
            
            canvas.lock();
            canvas.colorTransform(canvas.rect,ctrans);
            canvas.draw(temp,null,null,"add");
            canvas.unlock();
        }
    }
}