tags:

views:

117

answers:

2

i want to set fade effect to the GridRow when i remove it using removeChld() function

please tell me the solution ...

A: 

You can't use a Fade effect on a DataGridColumn instance because it has no "alpha" property (which is used by the Fade effect)

just_a_dude
pls read question properly , i want to add fade effect to GridRow not DataGridColumn
Tushar Ahirrao
A: 

You can do this:

<?xml version="1.0" encoding="utf-8"?>
<mx:Grid xmlns:mx="http://www.adobe.com/2006/mxml"&gt;
    <mx:Script>
     <![CDATA[
      import flash.display.DisplayObject;

      import mx.containers.GridRow;
      import mx.effects.Effect;
      import mx.effects.Fade;
      import mx.events.EffectEvent;

      override public function removeChild(child:DisplayObject):DisplayObject {
       if(child is GridRow) {
        var fade:Fade = new Fade;
        fade.alphaFrom = 1;
        fade.alphaTo = 0;
        fade.addEventListener(EffectEvent.EFFECT_END, fadeEndHandler);
        fade.play([child]);
       } else {
        super.removeChild(child);
       }

       return child;
      }

      private function fadeEndHandler(e:EffectEvent):void {
       super.removeChild(GridRow(e.effectInstance.target));
      }

     ]]>
    </mx:Script>
</mx:Grid>

Make this a new MXML component, like FadingGrid, and use as normal. However, now removeChildAt is not overridden and thus using it won't produce the fade effect.

tehmou
This looks good, though I haven't tried it. Tushar, I am assuming you have a button to fire the removeChild() function. I would implement this by using that button to call the fade effect like shown and on the event listener EffectEvent.EFFECT_END call the removeChild() function, then you don't have to override anything.
invertedSpear
Yes, you could have a button to call removeChild(). Of course, you have to know which row you are deleting so that you can pass the row itself as a parameter. This piece of code does not work with removeChildAt() since it is not overridden.You could implement this effect the way you described, but wrapping the behavior into a new class makes it possible to reuse it elsewhere. All it really takes is creating one .mxml file and putting the code into it - the overrides may be intimidating, but they are in fact quite useful if you want to do custom things.
tehmou