I added the child each and Every time,once the child is added,when i add the next child the previous child is deleted this is my goal. am trying to remove the Child ,But Nothing Displayed in my screen. here my coding
var tf:TextField = new TextField();
tf.text = chatData.message;<---------here i add the text dynamically
listChat.addChild(tf); // <----------------------------------here i added the child
var t:Timer = new Timer(150);
t.addEventListener(
TimerEvent.TIMER,
function(ev:TimerEvent): void
{
tf.text = tf.text.substr(1) + tf.text.charAt(0);
}
);
t.start();
listChat.removeChild(tf);// <----------------------------------here i remove the child
}
how can i remove the child? Anybody help me,Thanks in Advance!
finally i got Answer here my Coding
var myFormat:TextFormat = new TextFormat();
myFormat.size = 35;
var tf:TextField = new TextField();
tf.maxChars=100;
tf.text = chatData.message;
tf.defaultTextFormat=myFormat;
tf.autoSize = TextFieldAutoSize.LEFT;
tf.x = tf.y = 100;
listChat.addChild(tf);
var t:Timer = new Timer(150);
t.addEventListener(
TimerEvent.TIMER,
function(ev:TimerEvent): void{
tf.text = tf.text.substr(1) + tf.text.charAt(0);
}
);
t.start();
if(listChat!=null)
for (var i:int = listChat.numChildren-2; i >= 0; i--)
{
listChat.removeChildAt (i);//here i remeve the Child
}
}