How can I trigger a transition effect when a child control is added or removed in flex?
I've got a custom component that has children components dynamically added and removed to it depending on what button the user clicks. What I would like to do is trigger a transition effect that moves the child component onto the stage when it's added and then moves it off when it's removed.
Does anyone have a good example on how to accomplish this?
Edit: I figured it out and left my solution below. I ho开发者_如何学编程pe it helps someone else!
I just figured out how to get this working. Here's the answer I came up with. I hope that it helps someone else that has the same question!
MyContainerComponent
is the parent control I'm adding the children controls to and MyCustomChildControl
is the control I want to show the transitions for. The moveIn
and moveOut
arguments are the transition effects I've created.
public function AddChildComponent():void
{
var newChild:MyCustomChildControl= new MyCustomChildControl();
newChild.name = "ChildControl";
newChild.setStyle("addedEffect", moveIn);
newChild.setStyle("removedEffect", moveOut);
MyContainerComponent.addChild(newChild);
}
精彩评论