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: Perlin

Get Adobe Flash player
by makc3d 03 Jul 2009
/**
 * Copyright makc3d ( http://wonderfl.net/user/makc3d )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/zFGG
 */

// forked from UNDERCOVER's Perlin
package {
    import flash.display.Sprite;
    import flash.display.BitmapData;
    import flash.display.Bitmap
	import flash.geom.ColorTransform;
    import flash.geom.Point;
    import flash.events.Event;
    public class FlashTest extends Sprite {
        private var test:Sprite;
        private var canvas:BitmapData;
        private var random:Number = 0;
        protected var palette_r:Array = []; 
        protected var palette_g:Array = []; 
        protected var palette_b:Array = [];
        private var PointArrayA:Array;
        private var PointArrayB:Array;
        public function FlashTest() {
            // write as3 code here..
            var x:int, y:int; 
            for( x = 0; x < 256; x++ ) { 
                palette_r [x] = 0x10000 * int(128.0 + 128 * Math.sin(3.1415 * x / 16.0)); 
                palette_g [x] =   0x100 * int(128.0 + 128 * Math.sin(3.1415 * x / 128.0)); 
                palette_b [x] =       1 * 0; 
            }
            test = addChild(new Sprite()) as Sprite;
            PointArrayA = [];
            PointArrayB = [];
                for (var i:int = 0; i < 3; i++ ) {
                    PointArrayA[i] = new Point(Math.random()*stage.stageWidth,Math.random()*stage.stageHeight)
                    PointArrayB[i] = new Point(Math.random() * 10 - 5, Math.random() * 10 - 5);
                }
            canvas = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0x00FF0000);
            test.addChild(new Bitmap(canvas)) as Bitmap;
            addEventListener(Event.ENTER_FRAME, update);
        }
		private var ct:ColorTransform = new ColorTransform (1.7, 1.7, 1.7, 1, -100, -100, -100);
        private function update(e:Event):void {
            //random = Math.random() * 10000
            var i:int = 0;
            while (i < 3) {
                PointArrayA[i].x = PointArrayA[i].x + PointArrayB[i].x
                PointArrayA[i].y=PointArrayA[i].y+PointArrayB[i].y
                ++i;
            }
	   canvas.perlinNoise(stage.stageWidth, stage.stageHeight, 3 + int (mouseX / 100), random, false, true, 1, false, PointArrayA)
	   canvas.copyChannel (canvas, canvas.rect, canvas.rect.topLeft, 1, 2);
	   canvas.copyChannel (canvas, canvas.rect, canvas.rect.topLeft, 1, 4);
	   canvas.colorTransform (canvas.rect, ct);
	   
            canvas.paletteMap(canvas, canvas.rect, canvas.rect.topLeft, palette_r, palette_g, palette_b);
			var shift : int = 5; 
            while (shift -- > 0) { 
                palette_r.push (palette_r.shift ()); 
                palette_g.push (palette_g.shift ()); 
                palette_b.push (palette_b.shift ()); 
            }
        }
    }
}