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

ShimmeryText - 陽炎

Get Adobe Flash player
by cpu_t 25 Jun 2010
/**
 * Copyright cpu_t ( http://wonderfl.net/user/cpu_t )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/7ggv
 */

package
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.filters.BlurFilter;
    import flash.filters.DisplacementMapFilter;
    import flash.geom.ColorTransform;
    import flash.geom.Matrix;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    import flash.text.TextField;
    import flash.text.TextFormat;

    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);
            
            canvas=new BitmapData(SW,SH,false,0);
            var bddis:BitmapData=canvas.clone();
            bddis.perlinNoise(SW/4,SH/4,2,Math.random()*0xFFFFFFFF,true,false,2|4);
            displasementFilter=new DisplacementMapFilter(bddis,null,2,4,50,100,"clamp");
            
            var tf:TextField=new TextField();
            tf.defaultTextFormat=new TextFormat("Arial",64,0x201000,true);
            tf.text="Usagi Usausa";
            tf.autoSize="left";
            tf.filters=[new BlurFilter(8,8)]
            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);
            
            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();
        }
    }
}