There are number of cool filters available in Flash CS[X] such as Drop Shadow, Blur, Glow, Bevel etc. These can be applied very easily to any MovieClip dynamically using ActionScript. Follow these steps before adding the AS3 code for applying Drop Shadow filter:
- Draw a rectangle on stage and convert it into a new MovieClip by selecting it and pressing F8.
- Name it a “Box” and check the box Export for Action Script
- Close the MovieClip now, we are done with the drawing here.
Add this AS3 code on the first frame in Actions Panel:
//let's create a function to add drop shadow filter function addDropShadow(myMC):void { var dropShadow:DropShadowFilter = new DropShadowFilter(); dropShadow.distance = 0; dropShadow.angle = 45; dropShadow.color = 0x333333; dropShadow.alpha = 1; dropShadow.blurX = 10; dropShadow.blurY = 10; dropShadow.strength = 1; dropShadow.quality = 15; dropShadow.inner = false; dropShadow.knockout = false; dropShadow.hideObject = false; myMC.filters = new Array(dropShadow); } //create Box movieClip to attach drop shadow var myBox:Box = new Box(); myBox.width = 300; myBox.height = 200; myBox.x = 50; myBox.y = 100; //put it on stage addChild(myBox); //apply Drop Shadow filter addDropShadow(myBox); </pre> <h2>Dynamically Removing Drop Shadow Filter effect from a MovieClip</h2> Removing the Drop Shadow or any other filter is even easier, just add this one line where you want to remove the Drop Shadow effect: [actionscript3] myBox.filters = new Array();
In the above code, we reset the filter effect array and in case you have other filters applied to the MovieClip, only remove the DropShadow value from the Array values. By using an array, you can append more filters onto the same MovieClip like this:
myBox.filters = new Array(DropShadow, Glow, Blur, Others);
Of course, you will have to define other filters, just like DropShadow if you want to use them. Replicate the above addDropShadow function and give it a try.
Hope that helps.
Cheers!
i added filters to an image on rollover event and i want to remove this filters when i roll-out
i spend hours in this
you saved me
thank soooooooo much