|
|
|||||
Регистрация: Aug 2011
Сообщений: 100
|
Пауза между таймерами
Есть ф-ии
public function effText():void { frameTime = Math.round(textSpeed * 1 / this.stage.frameRate); charTimer = new Timer(frameTime); charTimer.addEventListener(TimerEvent.TIMER, charTimerComplete); charTimer.start(); charTimerTarget = txt1; charTimerTargetSource = 'Bad decisions\ncatching up with you?'; charTimerTargetData = charTimerTargetSource.split(''); charTimerTargetCount = 0; } public function charTimerComplete(event:TimerEvent):void { if (charTimerTargetCount < charTimerTargetData.length) { charTimerTarget.appendText(charTimerTargetData[charTimerTargetCount]); charTimerTargetCount ++; }else { switch(messageCount) { case 0: { txt1.text = ''; charTimerTargetSource = 'Improve your driving skills\nwith traffic school... Online!'; charTimerTargetData = charTimerTargetSource.split(''); charTimerTargetCount = 0; } break; case 1: { txt1.text = ''; charTimerTargetSource = 'Clear your record at\nyour own convenience.'; charTimerTargetData = charTimerTargetSource.split(''); charTimerTargetCount = 0; } break; case 2: { txt1.text = ''; txt1.y = 15; charTimerTargetSource = "Start your court-approved\ntraffic school\nbefore it's too late!"; charTimerTargetData = charTimerTargetSource.split(''); charTimerTargetCount = 0; } break; case 3: { charTimer.stop(); } break; } messageCount ++; } } |
|
|||||
забирай)
public function effText():void { frameTime = Math.round(textSpeed * 1 / this.stage.frameRate); charTimer = new Timer(frameTime); charTimer.addEventListener(TimerEvent.TIMER, charTimerComplete); charTimer.start(); charTimerTarget = txt1; charTimerTargetSource = 'Bad decisions\ncatching up with you?'; charTimerTargetData = charTimerTargetSource.split(''); charTimerTargetCount = 0; } private function latensy():void { var latensyTimer = new Timer(1500,1); //задержка 1,5 секунды latensyTimer.addEventListener(TimerEvent.TIMER, latensyTimerComplete); latensyTimer.start(); } private function latensyTimerComplete(e:TimerEvent):void { switch(messageCount) { case 0: { txt1.text = ''; charTimerTargetSource = 'Improve your driving skills\nwith traffic school... Online!'; charTimerTargetData = charTimerTargetSource.split(''); charTimerTargetCount = 0; } break; case 1: { txt1.text = ''; charTimerTargetSource = 'Clear your record at\nyour own convenience.'; charTimerTargetData = charTimerTargetSource.split(''); charTimerTargetCount = 0; } break; case 2: { txt1.text = ''; txt1.y = 15; charTimerTargetSource = "Start your court-approved\ntraffic school\nbefore it s too late!"; charTimerTargetData = charTimerTargetSource.split(''); charTimerTargetCount = 0; } break; case 3: { charTimer.stop(); } break; } messageCount ++; } public function charTimerComplete(event:TimerEvent):void { if (charTimerTargetCount < charTimerTargetData.length) { charTimerTarget.appendText(charTimerTargetData[charTimerTargetCount]); charTimerTargetCount ++; }else { switch(messageCount) { case 0: { // то что нужно выполнить сразу перенеси сюда из latensyTimerComplete } break; case 1: { } break; case 2: { } break; case 3: { } break; } latensy(); } } Последний раз редактировалось Newred; 02.09.2011 в 03:47. Причина: } забыл скобку в конце функции |
|
|||||
Регистрация: Aug 2011
Сообщений: 100
|
Цитата:
C:\Users\Armen\Desktop\b\Main.as, Line 344 1013: The private attribute may be used only on class property definitions. Вы имели в виду так? private function effText():void { frameTime = Math.round(textSpeed * 1 / this.stage.frameRate); charTimer = new Timer(frameTime); charTimer.addEventListener(TimerEvent.TIMER, charTimerComplete); charTimer.start(); charTimerTarget = txt1; charTimerTargetSource = 'Bad decisions\ncatching up with you?'; charTimerTargetData = charTimerTargetSource.split(''); charTimerTargetCount = 0; } private function latensy():void { var latensyTimer = new Timer(1500,1); //задержка 1,5 секунды latensyTimer.addEventListener(TimerEvent.TIMER, latensyTimerComplete); latensyTimer.start(); } private function latensyTimerComplete(event:TimerEvent):void { switch(messageCount) { case 0: { txt1.text = ''; charTimerTargetSource = 'Improve your driving skills\nwith traffic school... Online!'; charTimerTargetData = charTimerTargetSource.split(''); charTimerTargetCount = 0; } break; case 1: { txt1.text = ''; charTimerTargetSource = 'Clear your record at\nyour own convenience.'; charTimerTargetData = charTimerTargetSource.split(''); charTimerTargetCount = 0; } break; case 2: { txt1.text = ''; txt1.y = 15; charTimerTargetSource = "Start your court-approved\ntraffic school\nbefore it s too late!"; charTimerTargetData = charTimerTargetSource.split(''); charTimerTargetCount = 0; } break; case 3: { charTimer.stop(); } break; } messageCount ++; } private function charTimerComplete(event:TimerEvent):void { if (charTimerTargetCount < charTimerTargetData.length) { charTimerTarget.appendText(charTimerTargetData[charTimerTargetCount]); charTimerTargetCount ++; }else { switch(messageCount) { case 0: { txt1.text = ''; charTimerTargetSource = 'Improve your driving skills\nwith traffic school... Online!'; charTimerTargetData = charTimerTargetSource.split(''); charTimerTargetCount = 0; }break; case 1: { txt1.text = ''; charTimerTargetSource = 'Clear your record at\nyour own convenience.'; charTimerTargetData = charTimerTargetSource.split(''); charTimerTargetCount = 0; }break; case 2: { txt1.text = ''; txt1.y = 15; charTimerTargetSource = "Start your court-approved\ntraffic school\nbefore it s too late!"; charTimerTargetData = charTimerTargetSource.split(''); charTimerTargetCount = 0; }break; case 3: { charTimer.stop(); }break; } latensy(); } } |
|
|||||
Регистрация: Aug 2011
Сообщений: 100
|
Цитата:
Я так понял, что идет наложение текста один на другой |
|
|||||
1 секунда = 1000 мс
В данном случае функция выполняется примерно 50 раз в секунду(1000/21) если в коде поменять frameTime = 1000; // будет задержка в 1 секунду. ps можете мне в личку скинуть исходники, поправлю. |
Часовой пояс GMT +4, время: 23:15. |
|
« Предыдущая тема | Следующая тема » |
Теги |
timer |
|
|