# Stop typewriter when loading new text

**URL:** <https://forum.kirupa.com/t/stop-typewriter-when-loading-new-text/224279>\
**Category:** Uncategorized\
**Created:** [April 30, 2007, 8:47pm UTC](https://forum.kirupa.com/t/stop-typewriter-when-loading-new-text/224279 "2007-04-30T20:47:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fr\_ode](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@fr\_ode](https://forum.kirupa.com/u/fr_ode)\
**Post date:** [April 30, 2007, 8:47pm UTC](https://forum.kirupa.com/t/stop-typewriter-when-loading-new-text/224279/1 "2007-04-30T20:47:27Z")

</div>

I’m having an issue when I’m trying to load new text into a typewriter function before it has finished writing the first text. Does anybody know how I can stop it?

```auto
TextField.prototype.typeWriter = function(str, ms) {
    var me = this;
    var i = 0;
    var itv = setInterval(function () {
        me.text = str.substring(0, i);
        i++;        
        if (i>str.length) {
            clearInterval(itv);
        }
        updateAfterEvent();
    }, ms);
};

```

(it’s found here [http://proto.layer51.com/d.aspx?f=493](http://proto.layer51.com/d.aspx?f=493))
