# Typewrite Effect - with loop

**URL:** <https://forum.kirupa.com/t/typewrite-effect-with-loop/313100>\
**Category:** flash\
**Created:** [August 20, 2010, 12:10am UTC](https://forum.kirupa.com/t/typewrite-effect-with-loop/313100 "2010-08-20T00:10:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![esferaweb](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/esferaweb/32/2104_2.png) [@esferaweb](https://forum.kirupa.com/u/esferaweb)\
**Post date:** [August 20, 2010, 12:10am UTC](https://forum.kirupa.com/t/typewrite-effect-with-loop/313100/1 "2010-08-20T00:10:50Z")

</div>

Hi,

i´ve found this code with typewrite simulation,

but just work for one sentence. how can i change the code to use for more sentences and with loop?

```php
function typewriter(textBox:TextField, string:String, speed:int):void {

    var stringLength:Number = string.length;
    var counter:Number = 1;

    function wait() {

        if(counter == stringLength) {

            clearInterval(myTimer);

        }

        textBox.text = string.substr(0,counter);
        counter++;

    }

    var myTimer = setInterval(wait, speed);

}

typewriter(textbox, "Semper et ubíque unum ius", 50);

```
