Вопрос

I hope I can word this properly.

I'm wondering if it is possible to delay the output of letters in a string so it appears as if someone is typing?

I'm currently using JCreator and outputting to the console.

I've used thread.sleep, but this delays the output of the full string.

Any ideas? Let me know if I need to change up the wording.

Это было полезно?

Решение

You need to slice the string and push each character to an array. Then, use for loop to apply your function to each element in your array.

Here's a sample function I made using AS3:

function splitString(str:String):Array{
    var arr = [];
    for(var i=0;i<str.length;i++){
        arr.push(str.substr(i,1));
    }
    return arr;
}

to apply:

for(var a=0;a<str_split.length;a++){
     //trace(str_split[a]);
     //apply here your function    
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top