# Prototype for play but how to stop it?

**URL:** <https://forum.kirupa.com/t/prototype-for-play-but-how-to-stop-it/280329>\
**Category:** Uncategorized\
**Created:** [January 26, 2009, 12:20pm UTC](https://forum.kirupa.com/t/prototype-for-play-but-how-to-stop-it/280329 "2009-01-26T12:20:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MattiasA](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@MattiasA](https://forum.kirupa.com/u/MattiasA)\
**Post date:** [January 26, 2009, 12:20pm UTC](https://forum.kirupa.com/t/prototype-for-play-but-how-to-stop-it/280329/1 "2009-01-26T12:20:29Z")

</div>

```auto
MovieClip.prototype.play2 = function(direction, playback, begin, end, callback, clips) {

    var o = this;

    playback = (playback == undefined) ? (1000/24) : playback;
    end = (end == undefined) ? function() {return o._totalframes} : end;
    begin = (begin == undefined) ? 1 : begin;

    if (clips == undefined) {
        o.gotoAndStop(begin);
        o.curFrame = o._currentframe;
    } else {
        var len = clips.length;
        for (var n = 0; n<len; n++) {
            o[clips[n]].gotoAndStop(begin);
            o[clips[n]].curFrame = o[clips[n]]._currentframe;
        }
    }
    _global["id"+o._name] = setInterval(function () {
        if (clips == undefined) {
            o.curFrame += direction;
            o.gotoAndStop(o.curFrame);
            if (o.curFrame == end) {
                clearInterval(_global["id"+o._name]);
                delete (o.curFrame);
                callback(o);
            }
        } else {
            for (var n = 0; n<len; n++) {
                o[clips[n]].curFrame += direction;
                o[clips[n]].gotoAndStop(o[clips[n]].curFrame);
            }
            if (o[clips[0]].curFrame == end) {
                clearInterval(_global["id"+o._name]);
                for (var n = 0; n<=len; n++) {
                    delete (o[clips[n]].curFrame);
                }
                callback(o);
            }
        }
    }, playback);
};

```

This is a great prototype for specific play needs. But how do I stop it??? The usual commands does not seem to work. Any ideas are very welcome. I am not a total newbie, but almost :glasses:

Give it a try and you will see!
