EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 527

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Working with filters using ActionScript 527
The first section of code uses the MovieClipLoader class to load a JPEG image onto the
Stage. After the image completely loads, you reposition the image to the center of the
Stage. Then you use the Tween class to animate the image brightness level. To animate the
brightness, you use the
Object.watch() method, which registers an event handler that
you start when a specified property of an ActionScript object changes. Whenever some
ActionScript tries to set the custom brightness property of the
target_mc instance, you
call the
brightnessWatcher function. The custom brightnessWatcher function creates
a new array, which uses the color matrix filter to set the target image’s brightness to a
specified amount.
3. Select Control > Test Movie to test the document.
After the image loads and is placed on the Stage, the images brightness animates between
-100 and 100. After the brightness tween is complete, the animation is reversed using the
Tween.yoyo() method, which causes the tween to constantly animate.
Using the convolution filter
The ConvolutionFilter class applies a matrix convolution filter effect. A convolution
combines pixels in a source image that you specify with neighboring pixels to produce an
image. You can achieve a wide variety of imaging operations by using the convolution filter,
which includes blurring, edge detection, sharpening, embossing, and beveling effects.
A matrix convolution is based on an n x m matrix, which describes how a given pixel value in
the input image is combined with its neighboring pixel values to produce a resulting pixel
value. Each resulting pixel is determined by applying the matrix to the corresponding source
pixel and its neighboring pixels.
This filter is only available by using ActionScript. For more information on this filter, see
ConvolutionFilter (flash.filters.ConvolutionFilter) in the ActionScript 2.0 Language
Reference.
The following procedure applies the convolution filter to a dynamically loaded JPEG image.
NOTE
You can apply this filter on bitmaps and movie clip instances.

Table of Contents

Related product manuals