how to put some shadow effect to image in adobe flex

Posted on 2011-04-21
Last Modified: 2012-08-14
Hi Expert,

I have two images , when i click first image, i need to put some shadow effect on that image, and the shadow should disappear on first image when i click second image. This time shadow has to be appear on second image. it is kind of which image i have selected.
Please can i have some sample code for getting this shadow effect?


Question by:Alpita
    LVL 8

    Expert Comment

    Try this one:

    private function changeImage():void
     var MyFilter : DropShadowMyFilter = new DropShadowMyFilter();
     MyFilter.blurX = 5;
     MyFilter.blurY = 5;
     MyFilter.quality = 3;
     MyFilter.alpha = 0.5;
     MyFilter.angle = 45;
     MyFilter.color = 0x202020;
     MyFilter.distance = 7;
     MyFilter.inner = false;
     modifiedImage.MyFilters = [ MyFilter ];           

    Open in new window

    LVL 29

    Accepted Solution

    Use flash.filters.DropShadowFilter class

    import flash.filters.DropShadowFilter;

    private var lastShadowImage:Image;

    private function showShadow(event:Event):void{
                lastShadowImage.filters = null;
          lastShadowImage = as Image;
          var shadow:DropShadowFilter = new DropShadowFilter();
          shadow.distance = 10;
          shadow.angle = 25;
          lastShadowImage.filters = [shadow];

    <mx:Image source="@Embed(source='Images1.png')" mouseDown="showShadow(event)"/>
    <mx:Image source="@Embed(source='Images2.png')" mouseDown="showShadow(event)"/>

    Author Comment

    thanks for the response. It is showing effect now, but i have third image which should not show effect(just image with out any effects). When i click third image, previous selected image effect is disappearing, it should not disappear with click of third image. I used removeEventListener() for third image.

    I did like this:
    if(data.deviceType == "CLOUD") {
                                        image.removeEventListener(MouseEvent.MOUSE_DOWN, onClick);
                                        image.removeEventListener(MouseEvent.MOUSE_UP, onClick);            
    private function onClick():void{

    any thing wrong in my code?
    LVL 29

    Expert Comment

    Why do u need to assign event for your third image from begging?
    Don't call my function

    <mx:Image source="@Embed(source='Images3.png')">
    LVL 29

    Expert Comment

    Are you sure you excepted a correct answer?

    Author Comment

    I dont know why it is showing like this.
    I just accepted the solution
    LVL 29

    Expert Comment

    But you accepted your comments, I will glad if you will accept a correct answer.

    Expert Comment

    Restarting the close process.

    Experts Exchange Moderator

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Suggested Solutions

    First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
    Local Continuous Replication is a cost effective and quick way of backing up Exchange server data. The following article describes the steps required to configure Local Continuous Replication. Also, the article tells you how to restore from a backup…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now