Using filters from the ActionScript level
To apply any filter from the ActionScript 3 we use the "filters" property of every display object. All the filters are available from the flash.filters package. The example below presents how simple is to apply a filter to the MovieClip instance.
Box is a MovieClip of square placed in library.
First we need to instantiate one of the filters. I created two variables that are instances of the GlowFilter and the DropShadowFilter respectively. The filters constructors take plenty of parameters (like color, alpha, strength, etc...), but if we don't pass any, defaults will be used. Flash Help provides list of all parameters and examples. If we want to add or change any filter parameters later we can do that by applying a new value to a object property like glow.color = 0xFFFFFF. But it's important to remember that when we assign the array of a filter instance to the MovieClip or any other display object, this is actually a cloning of this array. So after any change we made to the filter instances, we need to overwrite a filter property again to take effect.
Removing a filter from the display object is the same process as removing an element from an array. And again we need to overwrite filter property of an object.
1 |
import flash.display.MovieClip; |

