Effect of removing effect 3 3FromStage

I am removing a component from WindowedApplication using removeChildAt () and want to play an effect (defined inside the component, say mx: Resize) that reduces the height of the component (hbox) to 0 removed.

I used the removedFromStage event on the component, but it just disappears (no effect playing). I think it gets removed before the effect is rendered. Is there a way to reproduce the effect, which is preferably defined in the component, before the removeChild function finishes?

Thank.

+2


source to share


3 answers


I transferred the effect to the parent like this:

var contentBox:VBox = new VBox();
var cm:HBox = new Hbox();
cm.setStyle('removedEffect', CloseDown);
contentBox.addChildAt(cm, 0);
//in another function
contentBox.removeChild(0);

      



It works. When I had the effect in the component itself it didn't work, alas.

0


source


removedFromStage will be fired after the component is removed (suitable for cleaning / managing memory). Most Flex components have a removeEffect property. This is what you want to use.



0


source


Refer to the mx.effects.Resize help page in Flex Builder for a list of events.

Basically what you need to do with your code:

  • create a resize event.

  • add an event listener for the end of the effect

  • play effect

  • when the effect is over, you will close the window.

The code should look like this:

public function close():void
{
    var resize:Resize   = new Resize();
    resize.heightTo     = 0;
    resize.duration     = 500;
    resize.addEventListener(EffectEvent.EFFECT_END, onCloseEffectEndHandler);

    resize.play([this]);    

}

private function onCloseEffectEndHandler(event:EffectEvent):void
{
    PopUpManager.removePopUp(this);
}

      

NOTE: WHEN YOU SHOW THE WINDOW, DO NOT FORGET TO SET THE HEIGHT FULLY, IT REMAINS 0 AND YOU SEE NOTHING!

0


source







All Articles