1. Create a flash document which is 256pixels X 256pixels;
2. Import the image to library;
3. Right click the image in the library and then click “Linkage Properties”;
4. Name the “Identifier” as “surface” and check “Export for ActionScript” and “Export in first frame”;
5. Write actionscript in the first frame:
var damper = new flash.display.BitmapData(128, 128, false, 128);
var result = new flash.display.BitmapData(128, 128, false, 128);
var result2 = new flash.display.BitmapData(256, 256, false, 128);
var source = new flash.display.BitmapData(128, 128, false, 128);
var buffer = new flash.display.BitmapData(128, 128, false, 128);
var output = new flash.display.BitmapData(256, 256, true, 128);
var surface = flash.display.BitmapData.loadBitmap(“surface”);
var bounds = new flash.geom.Rectangle(0, 0, 128, 128);
var origin = new flash.geom.Point();
var matrix = new flash.geom.Matrix();
var matrix2 = new flash.geom.Matrix();
matrix2.a = matrix2.d = 2;
var wave = new flash.filters.ConvolutionFilter(3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1], 9, 0);
var damp = new flash.geom.ColorTransform(0, 0, 9.960937E-001, 1, 0, 0, 2, 0);
var water = new flash.filters.DisplacementMapFilter(result2, origin, 4, 4, 48, 48, “ignore”);
attachBitmap(output, 0);
var ms = getTimer();
var frame = 0;
var mouseDown = false;
onMouseDown = function ()
{
mouseDown = true;
};
onMouseUp = function ()
{
onEnterFrame();
mouseDown = false;
};
onEnterFrame = function ()
{
if (mouseDown)
{
var _loc2 = _xmouse / 2;
var _loc1 = _ymouse / 2;
source.setPixel(_loc2 + 1, _loc1, 16777215);
source.setPixel(_loc2 – 1, _loc1, 16777215);
source.setPixel(_loc2, _loc1 + 1, 16777215);
source.setPixel(_loc2, _loc1 – 1, 16777215);
source.setPixel(_loc2, _loc1, 16777215);
} // end if
result.applyFilter(source, bounds, origin, wave);
result.draw(result, matrix, null, “add”);
result.draw(buffer, matrix, null, “difference”);
result.draw(result, matrix, damp);
result2.draw(result, matrix2, null, null, null, true);
output.applyFilter(surface, new flash.geom.Rectangle(0, 0, 256, 256), origin, water);
buffer = source;
source = result.clone();
};

Thanks, rainelaw!
This is exactly what I was looking for.
Cheers,
iorgu
By: iorgu on February 11, 2008
at 4:22 pm
Hi,
This doesn’t seem to be working.
I’ve strictly followed the directions and even trippled checked everything.
I created a new flash documents with 256px X 256 px dimensions
-Then I imported an image and also sized it to the same specs
- right clicked on the image and entered the word – surface into the identifyer box and checked the “Export for ActionScript” & “Export in first frame” boxes
-The only thing I was confused about was whether the actions script that you provided should go into the first frame of the symbol or the first frame of the scene? (Ive tried them both)
I’ve rendered to movie – and No action happens –
Am I missing something?
AC
By: AC on March 24, 2008
at 8:42 am
me neither.
By: Jack on July 31, 2008
at 2:46 am
not working…at alll…..
By: lokesh menghani on October 10, 2008
at 5:23 am
hi,
it works for me.
how could I get the pic back when the wave is over?
it stays a little bit wavy forever…
thanks,
gabka
By: gabka on November 19, 2008
at 2:36 pm
replace this:
”
with this:
‘
in the script.
So that “surface” becomes: ’surface’ and
“ignore”->’ignore’
“add”->’add’
“difference” ->’difference’
and it works perfectly!
this is how it should look like:
———————
var damper = new flash.display.BitmapData(128, 128, false, 128);
var result = new flash.display.BitmapData(128, 128, false, 128);
var result2 = new flash.display.BitmapData(256, 256, false, 128);
var source = new flash.display.BitmapData(128, 128, false, 128);
var buffer = new flash.display.BitmapData(128, 128, false, 128);
var output = new flash.display.BitmapData(256, 256, true, 128);
var surface = flash.display.BitmapData.loadBitmap(’surface’);
var bounds = new flash.geom.Rectangle(0, 0, 128, 128);
var origin = new flash.geom.Point();
var matrix = new flash.geom.Matrix();
var matrix2 = new flash.geom.Matrix();
matrix2.a = matrix2.d = 2;
var wave = new flash.filters.ConvolutionFilter(3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1], 9, 0);
var damp = new flash.geom.ColorTransform(0, 0, 9.960937E-001, 1, 0, 0, 2, 0);
var water = new flash.filters.DisplacementMapFilter(result2, origin, 4, 4, 48, 48, ‘ignore’);
attachBitmap(output, 0);
var ms = getTimer();
var frame = 0;
var mouseDown = false;
onMouseDown = function ()
{
mouseDown = true;
};
onMouseUp = function ()
{
onEnterFrame();
mouseDown = false;
};
onEnterFrame = function ()
{
if (mouseDown)
{
var _loc2 = _xmouse / 2;
var _loc1 = _ymouse / 2;
source.setPixel(_loc2 + 1, _loc1, 16777215);
source.setPixel(_loc2 – 1, _loc1, 16777215);
source.setPixel(_loc2, _loc1 + 1, 16777215);
source.setPixel(_loc2, _loc1 – 1, 16777215);
source.setPixel(_loc2, _loc1, 16777215);
} // end if
result.applyFilter(source, bounds, origin, wave);
result.draw(result, matrix, null, ‘add’);
result.draw(buffer, matrix, null, ‘difference’);
result.draw(result, matrix, damp);
result2.draw(result, matrix2, null, null, null, true);
output.applyFilter(surface, new flash.geom.Rectangle(0, 0, 256, 256), origin, water);
buffer = source;
source = result.clone();
};
————————-
Best wishes, iorgu
By: iorgu on December 2, 2008
at 2:24 am
working perfectly
But i have one problem – what should i change that this script working good with image at size 1024×376 pixels ??.
PS. sorry for my english :0
By: Lukasz on July 1, 2009
at 4:29 pm