User Guide
506 ActionScript classes
To apply filters to movie clips at runtime, use the filters property. Setting the filters
property of an object does not modify the object and can be undone by clearing the
filters
property.
To a p ply fil te r s t o Bi tm a pData instances, use the
BitmapData.applyFilter() method.
Calling
applyFilter() on a BitmapData object modifies that BitmapData object and
cannot be undone.
You can also apply filter effects to images and video at authoring time. For more information,
see your authoring documentation.
If you apply a filter to a movie clip or button, the
cacheAsBitmap property of the movie clip
or button is set to
true. If you clear all filters, the original value of cacheAsBitmap is
restored.
The filter uses the following formula:
dstPixel[x, y] = srcPixel[x + ((componentX(x, y) - 128) * scaleX) / 256, y +
((componentY(x, y) - 128) * scaleY) / 256]
where componentX(x, y) gets the componentX color value from the mapBitmap property at
(x - mapPoint.x ,y - mapPoint.y).
The map image used by the filter is scaled to match the Stage scaling. It is not scaled in any
way when the object itself is scaled.
This filter supports Stage scaling, but not general scaling, rotation, or skewing. If the object
itself is scaled (if x-scale and y-scale are not 100%), the filter effect is not scaled. It is scaled
only when the Stage is zoomed in.
Here is how the DisplacementMapFilter class works. For each pixel (x,y) in the destination
bitmap, the DisplacementMapFilter class does the following:
■ Gets the color from (x,y) in the map bitmap
■ Calculates an offset based on that color
■ Looks up that offset location (x+dx,y+dy) in the source bitmap
■ Writes that pixel to the destination(x,y), if boundary conditions permit
A filter is not applied if the resulting image would exceed 2880 pixels in width or height. For
example, if you zoom in on a large movie clip with a filter applied, the filter is turned off if the
resulting image reaches the 2880-pixel limit.
Availability: ActionScript 1.0; Flash Player 8
See also
applyFilter (BitmapData.applyFilter method), filters (MovieClip.filters
property)
, cacheAsBitmap (MovieClip.cacheAsBitmap property)