Use flash to create water waves.

Source: Internet
Author: User
After opening it, you can click the mouse on the screen, or press and hold the left mouse button without moving it over the screen. The circle ripple and ripple will appear. It is very beautiful, just like the real water, very beautiful. 1. Set the stage size (256x256 ). 2. Import images to the database. Do not import to the stage. 3. Open the library settings image link. The identifier is surface. Remove the "Import at runtime" check box, and check "export for ActionScript" and "export in the first frame" 4. insert action code 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 surfac E = 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], 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, matr IX, damp); result2.draw (result, matrix2, null, true); output. applyfilter (surface, new flash. geom. rectangle (0, 0,256,256), origin, water); buffer = source; Source = result. clone () ;}; 5. Test it. Click flash, and a ripple appears, the effect is very real. This is also the case. apply directly. 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 ("Bg1"); 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], 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 _ loc1 = _ xmouse/2; VaR _ loc2 = _ ymouse/2; source. setpixel (_ loc1 + 1, _ loc2, 16777215); source. setpixel (_ loc1-1, _ loc2, 16777215); source. setpixel (_ loc1, _ loc2 + 1, 16777215); source. setpixel (_ loc1, _ loc2-1, 16777215); source. setpixel (_ loc1, _ loc2, 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, true); output. applyfilter (surface, new flash. geom. rectangle (0, 0,256,256), origin, water); buffer = source; Source = result. clone ();};

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.