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 2012-10-11

...
@author https://twitter.com/lizhi525
Get Adobe Flash player
by lizhi 11 Oct 2012

    Talk

    makc3d at 11 Oct 2012 18:56
    Why does this code not load?
    makc3d at 11 Oct 2012 19:05
    nvm - does now
    lizhi at 12 Oct 2012 06:34
    it is slow now.but it is easy convert to pb2d or pb3d,stage3d.it is can get a ful speed.

    Tags

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

package  
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.BitmapDataChannel;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.filters.DisplacementMapFilter;
	import flash.geom.Point;
	import flash.utils.getTimer;
	/**
	 * ...
	 * @author https://twitter.com/lizhi525
	 */
	public class Test3 extends Sprite
	{
		private var bmd:BitmapData;
		private var bmd2:BitmapData;
		private var bmd3:BitmapData;
		public function Test3() 
		{
			bmd = new BitmapData(400, 400);
			bmd2 = bmd.clone();
			addChild(new Bitmap(bmd2));
			bmd2.perlinNoise(100, 100, 3, 1, true, true);
			bmd3 = bmd2.clone();
			addEventListener(Event.ENTER_FRAME, enterFrame);
		}
		
		private function enterFrame(e:Event):void 
		{
			var w:int = bmd.width;
			var h:int = bmd.height;
			bmd.lock();
			var t:uint = getTimer();
			var adx2:Number = (Math.sin(t/1000+3) + 1) * 200;
			var ady2:Number = (Math.sin(t/1000+.5) + 1) * 200;
			var adx3:Number = (Math.sin(t/1000+.8) + 1) * 200;
			var ady3:Number = (Math.sin(t/1000+1.5) + 1) * 200;
			for (var x:int = 0; x < w;x++ ) {
				for (var y:int = 0; y < h; y++ ) {
					var d:Number = Math.sqrt(x * x + y * y)+t/12;
					var v:Number = Math.sin(d / 4);
					d = Math.sqrt((x-adx2) * (x-adx2) + (y-ady2) * (y-ady2))+t/16;
					var v2:Number = Math.sin(d / 5);
					d = Math.sqrt((x-adx3) * (x-adx3) + (y-ady3) * (y-ady3))+t/34;
					var v3:Number = Math.sin(d / 4);
					v = ((v + 1) * 2 + (v2 + 1) * 3 + (v3 + 1) * 2) / 14 * 0xff;
					bmd.setPixel(x, y, v);
				}
			}
			bmd.unlock();
			bmd2.applyFilter(bmd3,bmd2.rect,new Point,new DisplacementMapFilter(bmd, null, BitmapDataChannel.BLUE, BitmapDataChannel.BLUE, 200,200));
			//filters = [new DisplacementMapFilter(bmd,null,BitmapDataChannel.BLUE,BitmapDataChannel.BLUE,10,10)];
		}
		
	}

}