Adding filters

Flash Player 9 and later, Adobe AIR 1.0 and later, requires Flash CS3 or later

If the target object of a motion tween contains filters, those filters are added using the initFilters() and addFilterPropertyArray() methods of the Motion class.

Initializing the filters array

The initFilters() method initializes the filters. Its first argument is an array of the fully qualified class names of all the filters applied to the display object. This array of filter names is generated from the filters list for the motion tween in Flash. In your copy of the script, you can remove or add any of the filters in the flash.filters package to this array. The following call initializes the filters list for the target display object. It applies the DropShadowFilter , GlowFilter , and BevelFilter and copies the list to each keyframe in the Motion object.
__motion_Box.initFilters(["flash.filters.DropShadowFilter", "flash.filters.GlowFilter", "flash.filters.BevelFilter"], [0, 0, 0]);

Adding filters

The addFilterPropertyArray() method describes the properties of an initialized filter with the following arguments:
  1. Its first argument identifies a filter by index. The index refers to the position of the filter name in the filter class names array passed in a previous call to initFilters() .

  2. Its second argument is the filter property to store for that filter in each keyframe.

  3. Its third argument is the value of the specified filter property.

Given the previous call to initFilters() , the following calls to addFilterPropertyArray() assign a value of 5 to the blurX and blurY properties of the DropShadowFilter . The DropShadowFilter is the first (index 0) item in the initialized filters array:
__motion_Box.addFilterPropertyArray(0, "blurX", [5]); 
__motion_Box.addFilterPropertyArray(0, "blurY", [5]);
The next three calls assign values to the quality, alpha, and color properties of the GlowFilter, the second item (index 1) in the initialized filter array:
__motion_Box.addFilterPropertyArray(1, "quality", [BitmapFilterQuality.LOW]); 
__motion_Box.addFilterPropertyArray(1, "alpha", [1.00]); 
__motion_Box.addFilterPropertyArray(1, "color", [0xff0000]);
The next four calls assign values to the shadowAlpha , shadowColor , highlightAlpha , and highlightColor of the BevelFilter , the third (index 2) item in the initialized filters array:
__motion_Box.addFilterPropertyArray(2, "shadowAlpha", [1.00]); 
__motion_Box.addFilterPropertyArray(2, "shadowColor", [0x000000]); 
__motion_Box.addFilterPropertyArray(2, "highlightAlpha", [1.00]); 
__motion_Box.addFilterPropertyArray(2, "highlightColor", [0xffffff]);

Adjusting color with the ColorMatrixFilter

After the ColorMatrixFilter has been initialized, you can set the appropriate AdjustColor properties to adjust the brightness, contrast, saturation, and hue of the tweened display object. Typically, the AdjustColor filter is applied when the motion tween is created in Flash; you can fine-tune it in your copy of the ActionScript. The following example transforms the hue and saturation of the display object as it moves.

__motion_Leaf_1.initFilters(["flash.filters.ColorMatrix"], [0], -1, -1); 
__motion_Leaf_1.addFilterPropertyArray(0, "adjustColorBrightness", [0], -1, -1); 
__motion_Leaf_1.addFilterPropertyArray(0, "adjustColorContrast", [0], -1, -1); 
__motion_Leaf_1.addFilterPropertyArray(0, "adjustColorSaturation", 
        -4.71232,-5.30136,-5.89041, 6.47945,-7.06849,-7.65753,-8.24657, 
    -1, -1); 
__motion_Leaf_1.addFilterPropertyArray(0, "adjustColorHue", 
    -1, -1);

// Ethnio survey code removed