1
我有這個AS3腳本(它工作正常),我只是想讓循環暫停每秒秒,然後它可以繼續循環。就像如果我喜歡它停下來Milliseconds.ThanksFlash AS3,如何暫停一個循環秒
var myText:String;
var counter:int = 0;
var format : TextFormat = new TextFormat();
format.size = 16;
format.font = "Verdana";
format.bold = true;
format.color = 0x000000;
var textField : TextField = new TextField();
textField.width = 200;
textField.height = 50;
textField.selectable = false;
textField.wordWrap = true;
textField.defaultTextFormat = format;
textField.x = textField.y =0;
addChild(textField);
\t \t \t \t
var textLoader:URLLoader = new URLLoader(new URLRequest("text.txt"));
textLoader.addEventListener(Event.COMPLETE, function(e:Event){initText(e.target.data);});
function initText(string:String):void{
\t myText = string;
\t addEventListener(Event.ENTER_FRAME, writeText);
}
function writeText(e:Event):void{
\t if (counter <= myText.length){
\t textField.text = myText.substr(0,counter);
\t counter++;
/*What I can put here to make it pause for a while*/
\t }
\t else{
\t \t removeEventListener(Event.ENTER_FRAME,writeText);
\t }
}
你可以看看[計時器](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/Timer.html#includeExamplesSummary)類。嘗試使用它來代替ENTER_FRAME來控制文本更新之間的延遲 –
將該函數剪切爲兩個,併爲'root'的'ENTER_FRAME'添加一個偵聽器,以稍後運行第二部分。 – iBug