actionscript 3 睡觉? [英] actionscript 3 sleep?

查看:36
本文介绍了actionscript 3 睡觉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的 actionscript 函数

I have a simple actionscript function

var string:String = "TEXT REMOVED";
var myArray:Array = string.split("");
addEventListener(Event.ENTER_FRAME, frameLooper);

function frameLooper(event:Event):void {
    if(myArray.length > 0) {
        text1.appendText(myArray.shift());
    }else{
        removeEventListener(Event.ENTER_FRAME, frameLooper);
    }
}

我想让它在调用 framelooper 后进入睡眠状态,所以它会慢一点.我怎么能这样做?

And I want to have it sleep after calling the framelooper so it is a little bit slower. How could I do this?

顺便说一句,我是新手,在教程中发现了这段代码,这是一种文本输入效果,如果有更好的方法,请告诉我.

btw, I'm fairly new and found this code on a tutorial, it's a text typing effect, if there is a better way of doing this please let me know.

推荐答案

使用计时器:

var string:String = "TEXT REMOVED";
var myArray:Array = string.split("");
var timer : Timer = new Timer (1000, myArray.length);
timer.addEventListener (TimerEvent.TIMER, frameLooper);
timer.start();

function frameLooper(event:Event):void {
    text1.appendText(myArray.shift());
}

这将每秒执行 frameLooper,次数与数组的长度完全相同.

This will execute the frameLooper on every second for exactly as many times as the length of the array.

这篇关于actionscript 3 睡觉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆