filters (MovieClip.filters property)

public filters : Array

An indexed array containing each filter object currently associated with the movie clip. The flash.filters package contains several classes that define specific filters you can use.

Filters can be applied in the Flash authoring tool at design-time, or at runtime using ActionScript code. To apply a filter using ActionScript, you must make a temporary copy of the entire MovieClip.filters array, modify the temporary array, and then assign the value of the temporary array back to the MovieClip.filters array. You cannot directly add a new filter object to the MovieClip.filters array. The following code has no effect on the target movie clip, named myMC:

myMC.filters[0].push(myDropShadow);

To add a filter using ActionScript, you must follow the following steps (assume that the target movie clip is named myMC):

If the filters array is empty, you need not use a temporary array. Instead, you can directly assign an array literal that contains one or more filter objects that you created.

To modify an existing filter object, whether it was created at design-time or at runtime, you must use the technique of modifying a copy of the filters array:

To clear the filters for a movie clip, set filters to an empty array ([]).

At load time, if a movie clip has an associated filter, it is marked to cache itself as a transparent bitmap. From this point forward, as long as the movie clip has a valid filter list, the player caches the movie clip as a bitmap. This source bitmap is used as a source image for the filter effects. Each movie clip usually has two bitmaps: one with the original unfiltered source movie clip and another for the final image after filtering. The final image is used when rendering. As long as the movie clip does not change, the final image does not need updating.

If you are working with a filters array that contains multiple filters and you need to track the type of filter assigned to each array index, you can maintain your own filters array and use a separate data structure to track the type of filter associated with each array index. There is no simple way to determine the type of filter associated with each filters array index.

Availability: ActionScript 1.0; Flash Player 8

Example

The following example adds a drop shadow filter to a movie clip named myMC:

var myDropFilter = new flash.filters.DropShadowFilter();
var myFilters:Array = myMC.filters;
myFilters.push(myDropFilter);
myMC.filters = myFilters;

The following example changes the quality setting of the first filter in the array to 15 (this example works only if at least one filter object has been associated with the myMC movie clip):

var myList:Array = myMC.filters;
myList[0].quality = 15;
myMC.filters = myList;

See also


Version 8