views:

107

answers:

2

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?

A: 

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

Robusto
+1  A: 

You can listen to the EffectEnd event.

Check out here

Jason W