
Macromedia MAX 2005 - Anaheim, CA What’s New In Flash 8
114
import flash.display.BitmapData;
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("http://www.helpexamples.com/flash/images/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 = 30 * _xmouse / Stage.width;
var high:Number = 200 * _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 creates a text field with the instance name status_txt, which follows the mouse
pointer and displays the current values for the high and low parameters for the noise()
method. The setInterval() function changes the noise effect, which is updated every 100
milliseconds (1/10 of a second), by continuously calling the updateNoise() function. The high
and low parameters for the noise() method are determined by calculating the pointer's
current position on the Stage.
3. Select Control > Test Movie to test the document.
Moving the mouse pointer along the x-axis affects the low parameter; moving the mouse
pointer along the y-axis affects the high parameter.
The BitmapData class also lets you distort a dynamically loaded image by using a combination of a
perlinNoise() method effect and a displacement map filter. The following procedure shows
this.