The As BitmapData class creates a clutter effect

Source: Internet
Author: User
Tags setinterval

Create a new Flash document and save it as a noise.fla.
Add the following ActionScript to frame 1th of the timeline: import Flash.display.BitmapData;

The code is as follows Copy Code
This.createtextfield ("Status_txt", 90, 0, 0, 100, 20);
Status_txt.selectable = false;
Status_txt.background = 0xFFFFFF;
Status_txt.autosize = "Left";
function OnMouseMove () {
status_txt._x = _xmouse;
status_txt._y = _ymouse-20;
Updateafterevent ();
}
This.createemptymovieclip ("IMG_MC", 10);
Img_mc.loadmovie ("yun_qi_img/image1.jpg");
var noisebmp:bitmapdata = new BitmapData (Stage.width, Stage.height, true);
This.attachbitmap (Noisebmp, 20);
SetInterval (updatenoise, 100);
var Grayscale:boolean = true;
function Updatenoise (): Void {
var low:number = * _xmouse/stage.width;
var high:number = * _ymouse/stage.height;
Status_txt.text = "Low:" + math.round (Low) + ', High: ' + math.round (high);
Noisebmp.noise (Math.Round (Math.random () * 100000), low, High, 8, true);
}


This code uses the instance name Status_txt to create a text field that follows the mouse pointer and displays the current value of the high and low parameters for the noise () method. The SetInterval () function changes the clutter effect, and the clutter effect is updated every 100 milliseconds (1/10) of the Updatenoise () function by successive calls to it. The high and low parameters of the noise () method are determined by calculating the current position of the pointer on the stage.

Select Control > Test movie to test the document.
Moving the mouse pointer along the x-axis affects the low parameter, while moving the mouse pointer along the y-axis affects the high parameter.

The BitmapData class also allows you to distort dynamically loaded images by combining the Perlinnoise () method effect and the displacement map filter. The following procedure shows this effect.

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.