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

flash on 2010-9-23

Get Adobe Flash player
by hacker_szoe51ih 23 Sep 2010
    Embed
/**
 * Copyright hacker_szoe51ih ( http://wonderfl.net/user/hacker_szoe51ih )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/hAHx
 */

package {
    import adobe.utils.CustomActions;
    import flash.display.*;
    import flash.events.*;
    import flash.filters.DisplacementMapFilter;
    import flash.geom.Point;
    import flash.net.*;
    import flash.system.*;

    [SWF(width=465,height=465,backgroundColor=0xffffff,frameRate=45)]
    public class Main extends Sprite {
        
        public var photoBoxSp:Sprite;
        public var canvasBMD:BitmapData;
        public var photoBM:Bitmap;
        public var mapBMD:BitmapData;
        public var mapBM:Bitmap;
        public var perlinNum:Number = 0;
        public var lo:Loader;
        public var urlReq:URLRequest;
        public var pass:String = "photo.jpg";
        public var W:Number = stage.stageWidth;
        public var H:Number = stage.stageHeight;

        public function Main() {
            init();
        }
        
        public function init():void {
            urlReq=new URLRequest("http://farm5.static.flickr.com/4097/4941567163_0fa5cd2938.jpg");
            var myLoaderContext:LoaderContext = new LoaderContext(true);
            lo = new Loader();
            lo.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
            lo.load(urlReq,myLoaderContext);        }
        
        public function onComplete(e:Event):void {
            canvasBMD = new BitmapData(400,300);
            canvasBMD.draw(lo);
            photoBM = new Bitmap(canvasBMD);
            photoBoxSp = new Sprite();
            photoBoxSp.addChild(photoBM);
            addChild(photoBoxSp);
            photoBM.x = W / 2 - photoBM.width / 2;
            photoBM.y = H / 2 - photoBM.height / 2;
            stage.addEventListener(Event.ENTER_FRAME,onEnterFramer);
        }
        
        public function onEnterFramer(e:Event):void {
            perlinNum += 1;
            //canvasBMD.draw(lo);
            canvasBMD.applyFilter(canvasBMD, canvasBMD.rect, new Point(0, 0), displacementMap(perlinNum, perlinNum));
            photoBM.bitmapData = canvasBMD;
        }
        
        public function displacementMap(px:Number,py:Number):DisplacementMapFilter {
            var dis:DisplacementMapFilter = new DisplacementMapFilter();
            dis.mapBitmap = perlinMap(px, py);
            var po:Point = new Point(0,0);
            dis.mapPoint = po;
            var colChannel:uint = BitmapDataChannel.RED;
            var colChannel2:uint = BitmapDataChannel.BLUE;
            dis.componentX = colChannel;
            dis.componentY = colChannel2;
            dis.scaleX = 5;
            dis.scaleY = 20;
            var modest:String = new String("color");
            dis.mode = modest;
            return dis;
        }
        
        public function perlinMap(px:Number,py:Number):BitmapData {
            var bmd:BitmapData = new BitmapData(400,300);
            var baseX:Number = 90;
            var baseY:Number = 250;
            var numOctaves:uint = 1;
            var ramdomseed:int = 10;
            var stitch:Boolean = true;
            var factalNoize:Boolean = true;
            var channelOption:uint =BitmapDataChannel.RED|BitmapDataChannel.GREEN|BitmapDataChannel.BLUE ;
            var grayScale:Boolean = false;
            var offsets:Array = [new Point(px,0),new Point(0,py)];
            bmd.perlinNoise(baseX, baseY, numOctaves, ramdomseed, stitch, factalNoize, channelOption, grayScale, offsets);
            return bmd;
        }
        
        
        
        
        
        

    }


}