Create a new Flash document and save it as a dropshadowtransparent.fla.
Add the following ActionScript to frame 1th of the timeline: import Flash.filters.DropShadowFilter;
The code is as follows |
Copy Code |
system.security.allow Domain ("http://www.helpexamples.com"); var mcllistener:object = new Object (); Mcllistener.onloadinit = function (target_mc:movieclip): Void { target_mc._x = (Stage.width- Target_mc._width)/2; target_mc._y = (stage.height-target_mc._height)/2; var dropshadow:dropshadowfilter = new Dropshadowfilter (4, 0x000000, 0.5, 10, 10, 2, 3); target_mc.filters = [DropShadow]; }; Mcllistener.onloaderror = function (target_mc:movieclip): Void { trace ("Unable to load image.") ; }; This.createemptymovieclip ("LOGO_MC", 10); var my_mcl:moviecliploader = new Moviecliploader (); My_mcl.addlistener (Mcllistener); My_mcl.loadclip ("/images/logo.png", LOGO_MC); |
This ActionScript code uses the Moviecliploader class to load an image and applies a drop shadow filter when the image is loaded from the remote server.
Select Control > Test movie to test the Flash document.
Flash uses a transparent background to load the PNG image. When you apply a drop shadow filter, only the opaque part of the image applies the filter.