Flash Example Tutorial: AS3.0 to create beautiful watermark effect

Source: Internet
Author: User

In this flash AS3.0 example tutorial, we'll use the Displacementmapfilter (perlinnoise) of the substitution map filter (bitmapdata) and the class, and these two guys often bring us some exciting effects, Their cooperation today has created a beautiful water Timor for us.

And now I'm starting to build this beautiful watermark:

Since it is the watermark, I would like to first find a picture of water, Baidu, river, lake, pool, you like on the line.

1, a new AS3.0 document, the frame frequency set to 30, will you just Baidu to the picture into the library, point right, in the property panel in the "Use of JPEG import quality" before the hook to remove, so do the volume of the picture will be greatly reduced OH.

2. Create a new movie clip symbol, drag the picture to the stage, set the size of the picture, how big do you want to set it? Anyway, I'm pressing the default 550x400. The picture is as large as the size of the document. Click on the Alignment panel to center align relative to the stage.

3, back to the main scene, the MC dragged onto the stage, centered, set an instance name for it, I use the "pic" Layer locked.

4, the new insert a layer, the picture (note is the picture is not MC), drag onto the stage, open the alignment panel, wide-height matching, center alignment. Now 1th, the 2-layer image is completely coincident, please confirm that this is the case. Select the picture, click Modify > Separate, the water section selected, delete. You can hide the 1th layer to see the effect after the deletion.

The following figure:

5, a new layer to write code, open the Action panel, enter the following code:

1. var bmp:bitmapdata = new BitmapData (550,400);

2. var zh:displacementmapfilter = new Displacementmapfilter (bmp,new Point (0,0), 1,2,10,600);

3. var p1:point = new Point ();

4. var p2:point = new Point ();

5. var zdxg:array = [P1,P2];

6. AddEventListener (Event.enter_frame, LD);

7. Function ld (e:event): void {

8. zdxg[0].x = 0.2;

9. zdxg[1].y = 0.1;

Bmp.perlinnoise (168,5,2,4,TRUE,TRUE,2,TRUE,ZDXG);

Pic.filters = [en];

12.}

OK, test the film, a nice aqua effect immediately appears in front of you.

Code Analysis:

First declare a BitmapData class instance bmp with the same size as the picture, which is used as the parameter of the displacement map filter.

var bmp:bitmapdata = new BitmapData (550,400);

Then declare a displacement map filter en, BMP as a parameter.

var zh:displacementmapfilter = new Displacementmapfilter (bmp,new Point (0,0), 1,2,10,600);

The next two points are declared, and the two points are placed in an array called ZDXG, which will be used to generate the arguments for the miscellaneous points in BMP.

var p1:point = new Point ();

var p2:point = new Point ();

var zdxg:array = [P1,P2];

Then, call the LD function in the Enter_frame event.

AddEventListener (Event.enter_frame, LD);

ld function, dynamic change the location of two points, and then make the BMP application of the miscellaneous point function, at each frame of the interval to produce a different effect of the effect, so that the replacement filter effects of change, and finally let the film clip pic, apply filters to achieve the effect of water.

function ld (e:event): void {

zdxg[0].x + 0.2;

Zdxg[1].y + 0.1;

Bmp.perlinnoise (168,5,2,4,TRUE,TRUE,2,TRUE,ZDXG);

Pic.filters = [en];

}

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.