DisplacementMapFilter (flash.filters.DisplacementMapFilter)

Object
    |
    +-BitmapFilter
        |
        +-flash.filters.DisplacementMapFilter

public class DisplacementMapFilter
extends BitmapFilter

The DisplacementMapFilter class uses the pixel values from the specified BitmapData object (called the displacement map image) to perform a displacement of an object on the Stage, such as a MovieClip instance. You can use this filter to achieve a warped or mottled effect on a BitmapData or MovieClip instance.

The use of filters depends on the object to which you apply the filter.

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 apply filters to BitmapData 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:

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)

Property summary

Modifiers

Property

Description

alpha:Number

Specifies the alpha transparency value to use for out-of-bounds displacements.

color:Number

Specifies what color to use for out-of-bounds displacements.

componentX:Number

Describes which color channel to use in the map image to displace the x result.

componentY:Number

Describes which color channel to use in the map image to displace the y result.

mapBitmap:BitmapData

A BitmapData object containing the displacement map data.

mapPoint:Point

A flash.geom.Point value that contains the offset of the upper-left corner of the target movie clip from the upper-left corner of the map image.

mode:String

The mode for the filter.

scaleX:Number

The multiplier to use to scale the x displacement result from the map calculation.

scaleY:Number

The multiplier to use to scale the y displacement result from the map calculation.

Properties inherited from class Object

constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property)


Constructor summary

Signature

Description

DisplacementMapFilter(mapBitmap:BitmapData, mapPoint:Point, componentX:Number, componentY:Number, scaleX:Number, scaleY:Number, [mode:String], [color:Number], [alpha:Number])

Initializes a DisplacementMapFilter instance with the specified parameters.

Method summary

Modifiers

Signature

Description

clone() : DisplacementMapFilter

Returns a copy of this filter object.

Methods inherited from class BitmapFilter

clone (BitmapFilter.clone method)


Methods inherited from class Object

addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString method), unwatch (Object.unwatch method), valueOf (Object.valueOf method), watch (Object.watch method)