Показать сообщение отдельно
Старый 23.03.2017, 10:05
callme вне форума Посмотреть профиль Отправить личное сообщение для callme Найти все сообщения от callme
  № 2  
Ответить с цитированием
callme
 
Аватар для callme

Регистрация: Dec 2014
Сообщений: 312
Код AS3:
package
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.TimerEvent;
    import flash.text.TextField;
    import flash.utils.Timer;
 
    public class Main extends Sprite
    {
        private var textField:TextField;
        private var string:String;
        private var timer:Timer;
 
        public function Main()
        {
            string = "первая строка\nвторая строка";
            textField = new TextField();
            addChild(textField);
 
            timer = new Timer(100);
 
            timer.addEventListener(TimerEvent.TIMER, timer_timer);
            timer.start();
        }
 
        private function timer_timer(e:TimerEvent):void 
        {
            if (string.length > 0) {
                textField.appendText(string.charAt(0));
                string = string.substring(1);
            }
            else {
                timer.removeEventListener(TimerEvent.TIMER, timer_timer);
                timer.stop();
            }
        }
    }
}