2011-10-21 9 views
-1

私はそれぞれ子を追加しました。毎回、子が追加されると、前の子が削除された次の子を追加すると、これが私の目標です。子を削除しようとしていますが、画面に何も表示されません。 ここをクリックActionScript3で子を削除するには?

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 

} 

私は子供をどのように削除できますか?誰でも助けてくれて、ありがとう!

+0

listChatは、それが追加されていることと同じフレーム上のテキストフィールドを削除します。同様に、私はあなたのタイマー内のロジックが期待どおりにテキストをマーキーするとは信じていません。 –

+0

okチャイルドサーを削除するにはどうすればよいですか? – Mercy

+0

あなたのコードを追加するとすぐに私はあなたが言うと信じている子を削除します。「しかし、私の画面には何も表示されません。 –

答えて

0

は最終的に私はここに 回答しまった私のコーディング

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 
} 

} 
関連する問題