Chobicus
Chobicus

Reputation: 2094

How to do something after effect animation ends in Flex?

I'm a beginner in Flex so there must be more elegant way of doing this.

//move effect
private var m:Move = new Move(); 

//this function creates labels with some text and starts move effect on them
public function moveText(i:int):void {
    var myLabel:Label = new Label();
    myLabel.text = "some text"; 
    m.target = myLabel;
    ... 
    m.play();               
}

Method moveText is called in a loop so I guess that labels don't get "garbage collected".

What I want to do is to remove Labels created in moveText method after play animation ends.

Another way of doing this is maybe creating some kind of "pool" of labels which I would use to move arround text. I don't know how would I return labels in to "pool".

The question is how to do something after effect animation ends?

Upvotes: 0

Views: 696

Answers (2)

Robusto
Robusto

Reputation: 31913

Look at the effectEnd event in the Effect class. You can put a handler in there that does your garbage collection.

Upvotes: 0

Jason
Jason

Reputation: 2503

You can listen to the EffectEnd event.

Check out here

Upvotes: 2

Related Questions