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

testwater

...
@author lizhi
Get Adobe Flash player
by lizhi 06 May 2015
    Embed
/**
 * Copyright lizhi ( http://wonderfl.net/user/lizhi )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/rpqh
 */

package  
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.utils.getTimer;
    /**
     * ...
     * @author lizhi
     */
    public class TestWater extends Sprite
    {
        private var b:BitmapData;
        public function TestWater() 
        {
            b = new BitmapData(200, 200, false);
            addChild(new Bitmap(b));
            addEventListener(Event.ENTER_FRAME, enterFrame);
        }
        
        private function enterFrame(e:Event):void 
        {
            var t:Number = getTimer()/400;
            var scale:Number = 4;
            var wave:Number = Math.PI * 6 / b.height;
            b.lock();
            for (var x:int = 0; x < b.width;x++ ) {
                for (var y:int = 0; y < b.height; y++ ) {
                    var offsetY:Number = (Math.sin(x*wave/20+t))*30+(Math.sin(x*wave/5+t*2))*5;
                    var offsetX:Number = (2+Math.sin((y+offsetY)*wave+t)+Math.sin((y+offsetY)*wave*.7+t*2.4))/4;
                    b.setPixel(x, y, 0xff*(offsetX));
                }
            }
            b.unlock();
        }
        
    }

}