我想更改Alert on timer tick中的文本,但没有任何更改,请参见下面的示例:
private var alert:Alert;
private var timer:Timer = new Timer(1000, 0);
private function init(){
timer.addEventListener(TimerEvent.TIMER, onTimerTick);
timer.start();
alert = Alert.show("Logout in "+ 60 +" seconds","",3);
}
private function onTimerTick(event:TimerEvent):void{
alert.text = "Logout in "+(60-timer.currentCount)+" seconds";
}附注:标题通过这种方式被覆盖。
提前感谢您的帮助
发布于 2012-03-23 23:14:30
private var uiText:UITextField;
private function init():void{
timer.addEventListener(TimerEvent.TIMER, onTimerTick);
timer.start();
alert = Alert.show("Logout in "+ 60 +" seconds","",3);
var child:DisplayObjectContainer = alert.getChildAt(0) as DisplayObjectContainer;
uiText = child.getChildAt(0) as UITextField;
uiText.text;
}
private function onTimerTick(event:TimerEvent):void{
(timer.currentCount > 60) ? [timer.stop(), alert.parent.removeChild(alert)] : void;
uiText.text = "Logout in "+(60-timer.currentCount).toString()+" seconds";
}做一些这样的事情会有帮助的。
发布于 2012-03-23 23:15:20
好吧,这是相当丑陋的。
alert.mx_internal::alertForm.mx_internal::textField.text = "...";将允许您更新文本。它不是很漂亮,但它是有效的。
https://stackoverflow.com/questions/9840941
复制相似问题