MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 536

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

3.
Select Control > Test Movie to test the document.
Moving the mouse pointer along the x-axis affects the
pointer along the y-axis affects the
The BitmapData class also lets you distort a dynamically loaded image by using a
combination of a
perlinNoise()
procedure shows this.
To apply a displacement map filter to an image:
1.
Create a new Flash document and save it as displacement.fla.
2.
Add the following ActionScript to Frame 1 of the Timeline:
// Import classes.
import flash.filters.DisplacementMapFilter;
import flash.display.BitmapData;
import flash.geom.Point;
// Create a clip and a nested clip.
var shapeClip:MovieClip = this.createEmptyMovieClip("shapeClip", 1);
shapeClip.createEmptyMovieClip("holderClip", 1);
// Load JPEG.
var imageLoader:MovieClipLoader = new MovieClipLoader();
imageLoader.loadClip("http://www.helpexamples.com/flash/images/
image4.jpg", shapeClip.holderClip);
// Create BitmapData instance.
var perlinBmp:BitmapData = new BitmapData(Stage.width, Stage.height);
perlinBmp.perlinNoise(Stage.width, Stage.height, 10,
Math.round(Math.random() * 100000), false, true, 1, false);
// Create and apply the displacement map filter.
var displacementMap:DisplacementMapFilter = new
DisplacementMapFilter(perlinBmp, new Point(0, 0), 1, 1, 100, 100,
"color", 1);
shapeClip.filters = [displacementMap];
// Create and apply a listener.
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function():Void {
perlinBmp.perlinNoise(Stage.width, Stage.height, 10,
Math.round(Math.random() * 100000), false, true, 1, false);
shapeClip.filters = [displacementMap];
}
Mouse.addListener(mouseListener);
536
Animation, Filters, and Drawings
parameter.
high
method effect and a displacement map filter. The following
parameter; moving the mouse
low

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

This manual is also suitable for:

Flash 8

Table of Contents