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

LiquidFx

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

package {
    import flash.display.Sprite;
    import flash.display.Bitmap; 
    import flash.display.BitmapData; 
    import flash.display.Loader; 
    import flash.display.LoaderInfo;
    import flash.events.Event;
    import flash.net.URLRequest; 
    import flash.system.LoaderContext;
    import flash.events.MouseEvent;
    [SWF(width="465", height="465", backgroundColor="0xFFFFFF", frameRate="60")] 
    public class LiquidFx extends Sprite {
        private var main:Sprite;
        private var sub:Sprite;
        //
        private var w:int = 480;
        private var h:int = 480;
        //
        private var mainmask:Sprite;
        private var submask:Sprite;	
        //
        private var count:Number=0
        private var speed:Number=4;
        //
        public function LiquidFx() {
            var loader:Loader = new Loader(); 
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded); 
            loader.load(new URLRequest('http://www.k3lab.com/wonderfl/test.jpg'), new LoaderContext(true)); 

        }
        private function onImageLoaded(e:Event):void {
            var loader:Loader = Loader(LoaderInfo(e.target).loader);
            var original:BitmapData = Bitmap(loader.content).bitmapData;
            //表示用スプライト
              main = addChild(new Sprite()) as Sprite;
            main.graphics.beginBitmapFill(original, null, false)
            main.graphics.drawRect(0, 0, w, h);
            main.graphics.endFill();
            //エフェクト用スプライト
              sub = addChild(new Sprite()) as Sprite;
            sub.graphics.beginBitmapFill(original, null, false)
            sub.graphics.drawRect(0, 0, w, h);
            sub.graphics.endFill();
            sub.scaleX=100
            //各マスクセット
              mainmask = addChild(new Sprite()) as Sprite;
            submask = addChild(new Sprite()) as Sprite;
            main.mask = mainmask
            sub.mask = submask
            //
            stage.addEventListener(MouseEvent.MOUSE_DOWN, _down)
            addEventListener(Event.ENTER_FRAME,update)
        }
        private function _down(e:Event):void {
            count=0
        }
        private function update(e:Event):void {
            count +=speed
            sub.x = (0 - count) *sub.scaleX
            submask.graphics.clear();
            submask.graphics.beginFill(0x0);
            submask.graphics.moveTo(count, 0)
            submask.graphics.lineTo(w, 0)
            submask.graphics.lineTo(w, h)
            submask.graphics.lineTo(count, h)
            submask.graphics.lineTo(count, 0)
            submask.graphics.endFill()
            mainmask.graphics.clear();
            mainmask.graphics.beginFill(0);
            mainmask.graphics.moveTo(0, 0)
            mainmask.graphics.lineTo(count, 0)
            mainmask.graphics.lineTo(count, h)
            mainmask.graphics.lineTo(0, h)
            mainmask.graphics.lineTo(0, 0)
            mainmask.graphics.endFill()
        }
    }
}