# Setinterval called too quickly makes it stop working?

**URL:** <https://forum.kirupa.com/t/setinterval-called-too-quickly-makes-it-stop-working/182973>\
**Category:** Uncategorized\
**Created:** [March 22, 2006, 9:08pm UTC](https://forum.kirupa.com/t/setinterval-called-too-quickly-makes-it-stop-working/182973 "2006-03-22T21:08:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fourleafstudios](https://avatars.discourse-cdn.com/v4/letter/f/46a35a/32.png) [@fourleafstudios](https://forum.kirupa.com/u/fourleafstudios)\
**Post date:** [March 22, 2006, 9:08pm UTC](https://forum.kirupa.com/t/setinterval-called-too-quickly-makes-it-stop-working/182973/1 "2006-03-22T21:08:11Z")

</div>

I am having problems with this function, which is called when a button is pressed. I am loading a JPG with a movieClipLoader into a newly created movieclip, and while this is loading the other is still viewable and is faded and deleted when the new JPG has fully loaded, using the code below:

```
ActionScript Code:
[LEFT][COLOR=#993300]function[/COLOR] loadBigPicture[COLOR=#000000]([/COLOR]iValue:[COLOR=#993300]Number[/COLOR], firstTime:[COLOR=#993300]String[/COLOR][COLOR=#000000])[/COLOR]:[COLOR=#993300]Void[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]this[/COLOR].[COLOR=#993300]createEmptyMovieClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]"myBigPicture"[/COLOR]+iValue, [COLOR=#993300]this[/COLOR].[COLOR=#993300]getNextHighestDepth[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#993300]trace[/COLOR][COLOR=#000000]([/COLOR]_level0[COLOR=#000000][[/COLOR][COLOR=#0000FF]"myBigPicture"[/COLOR]+iValue[COLOR=#000000]][/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#993300]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]"loadBigPicture Called: "[/COLOR]+iValue[COLOR=#000000])[/COLOR];
mybigpic = [COLOR=#993300]new[/COLOR] [COLOR=#993300]Object[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
mybigpic.[COLOR=#000000]firstTime[/COLOR] = firstTime;
mybigpic.[COLOR=#993300]onLoadInit[/COLOR] = [COLOR=#993300]function[/COLOR][COLOR=#000000]([/COLOR]target_mc[COLOR=#000000])[/COLOR]:[COLOR=#993300]Void[/COLOR] [COLOR=#000000]{[/COLOR]
    target_mc.[COLOR=#993300]_alpha[/COLOR] = [COLOR=#000000]0[/COLOR];
    [COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#993300]_global[/COLOR].[COLOR=#000000]areComps[/COLOR] == [COLOR=#993300]true[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
        _level0[COLOR=#000000][[/COLOR][COLOR=#0000FF]"myBigPicture"[/COLOR]+[COLOR=#993300]_global[/COLOR].[COLOR=#000000]currentPic[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#000000]mysymbol[/COLOR] = [COLOR=#993300]setInterval[/COLOR][COLOR=#000000]([/COLOR]showISymbol, [COLOR=#000000]3000[/COLOR][COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR]
    [COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]firstTime == [COLOR=#0000FF]"yes"[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
        [COLOR=#993300]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]"firstTime"[/COLOR][COLOR=#000000])[/COLOR];
        _level0[COLOR=#000000][[/COLOR][COLOR=#0000FF]"myBigPicture"[/COLOR]+[COLOR=#993300]_global[/COLOR].[COLOR=#000000]currentPic[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#000000]mypic[/COLOR] = [COLOR=#993300]setInterval[/COLOR][COLOR=#000000]([/COLOR]brightenBigPic, [COLOR=#000000]1400[/COLOR][COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR] [COLOR=#993300]else[/COLOR] [COLOR=#000000]{[/COLOR]
        _level0[COLOR=#000000][[/COLOR][COLOR=#0000FF]"myBigPicture"[/COLOR]+lastPic[COLOR=#000000]][/COLOR].[COLOR=#000000]deleteBig[/COLOR] = [COLOR=#993300]setInterval[/COLOR][COLOR=#000000]([/COLOR]removeBigImage, [COLOR=#000000]500[/COLOR], lastPic[COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR]
    [COLOR=#993300]function[/COLOR] brightenBigPic[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
        target_mc.[COLOR=#000000]alphaTo[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]100[/COLOR],[COLOR=#000000]1[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#993300]clearInterval[/COLOR][COLOR=#000000]([/COLOR]_level0[COLOR=#000000][[/COLOR][COLOR=#0000FF]"myBigPicture"[/COLOR]+[COLOR=#993300]_global[/COLOR].[COLOR=#000000]currentPic[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#000000]mypic[/COLOR][COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR]
    [COLOR=#993300]function[/COLOR] removeBigImage[COLOR=#000000]([/COLOR]lastPic:[COLOR=#993300]Number[/COLOR][COLOR=#000000])[/COLOR]:[COLOR=#993300]Void[/COLOR] [COLOR=#000000]{[/COLOR]
        [COLOR=#993300]clearInterval[/COLOR][COLOR=#000000]([/COLOR]_level0[COLOR=#000000][[/COLOR][COLOR=#0000FF]"myBigPicture"[/COLOR]+lastPic[COLOR=#000000]][/COLOR].[COLOR=#000000]deleteBig[/COLOR][COLOR=#000000])[/COLOR];
        target_mc.[COLOR=#000000]alphaTo[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]0[/COLOR],[COLOR=#000000]1[/COLOR][COLOR=#000000])[/COLOR];
        [COLOR=#993300]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000FF]"removing: "[/COLOR]+_level0[COLOR=#000000][[/COLOR][COLOR=#0000FF]"myBigPicture"[/COLOR]+lastPic[COLOR=#000000]][/COLOR][COLOR=#000000])[/COLOR]
        [COLOR=#993300]removeMovieClip[/COLOR][COLOR=#000000]([/COLOR]_level0[COLOR=#000000][[/COLOR][COLOR=#0000FF]"myBigPicture"[/COLOR]+lastPic[COLOR=#000000]][/COLOR][COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR]
    [COLOR=#993300]function[/COLOR] showISymbol[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR]:[COLOR=#993300]Void[/COLOR] [COLOR=#000000]{[/COLOR] [COLOR=#993300]clearInterval[/COLOR][COLOR=#000000]([/COLOR]_level0[COLOR=#000000][[/COLOR][COLOR=#0000FF]"myBigPicture"[/COLOR]+[COLOR=#993300]_global[/COLOR].[COLOR=#000000]currentPic[/COLOR][COLOR=#000000]][/COLOR].[COLOR=#000000]mysymbol[/COLOR][COLOR=#000000])[/COLOR];
        theInformationBox.[COLOR=#000000]iSymbol[/COLOR].[COLOR=#993300]enabled[/COLOR] = [COLOR=#993300]true[/COLOR];
        theInformationBox.[COLOR=#000000]iSymbol[/COLOR].[COLOR=#000000]alphaTo[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]100[/COLOR], [COLOR=#000000]1[/COLOR], [COLOR=#0000FF]"easeOutQuad"[/COLOR][COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR];
bigimage_mcl = [COLOR=#993300]new[/COLOR] [COLOR=#993300]MovieClipLoader[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
bigimage_mcl.[COLOR=#993300]addListener[/COLOR][COLOR=#000000]([/COLOR]mybigpic[COLOR=#000000])[/COLOR];
bigimage_mcl.[COLOR=#993300]loadClip[/COLOR][COLOR=#000000]([/COLOR]imglocation[COLOR=#000000][[/COLOR]iValue[COLOR=#000000]][/COLOR], _level0[COLOR=#000000][[/COLOR][COLOR=#0000FF]"myBigPicture"[/COLOR]+iValue[COLOR=#000000]][/COLOR][COLOR=#000000])[/COLOR];

```

[COLOR=#000000]}[/COLOR]  
[/LEFT]

If the button is pressed extremely quickly again and again, the intervals begin to stop working, any ideas?

---

<div class="post-metadata">

**Author:** ![fourleafstudios](https://avatars.discourse-cdn.com/v4/letter/f/46a35a/32.png) [@fourleafstudios](https://forum.kirupa.com/u/fourleafstudios)\
**Post date:** [March 25, 2006, 12:54pm UTC](https://forum.kirupa.com/t/setinterval-called-too-quickly-makes-it-stop-working/182973/2 "2006-03-25T12:54:33Z")

</div>

has no one had this problem before?

---

<div class="post-metadata">

**Author:** ![fourleafstudios](https://avatars.discourse-cdn.com/v4/letter/f/46a35a/32.png) [@fourleafstudios](https://forum.kirupa.com/u/fourleafstudios)\
**Post date:** [March 28, 2006, 5:35pm UTC](https://forum.kirupa.com/t/setinterval-called-too-quickly-makes-it-stop-working/182973/3 "2006-03-28T17:35:41Z")

</div>

pleasse help, somebody must have been in the same situation before!

---

<div class="post-metadata">

**Author:** ![Thinker2501](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@Thinker2501](https://forum.kirupa.com/u/Thinker2501)\
**Post date:** [March 28, 2006, 5:51pm UTC](https://forum.kirupa.com/t/setinterval-called-too-quickly-makes-it-stop-working/182973/4 "2006-03-28T17:51:53Z")

</div>

use I boolean to note when you are loading an image and when you are not onLoadStart put \_root.isLoading = 1; then onLoadInit switch it to zero. On your button onRelease check if isLoading is true, if it is use unLoadClip() to stop the loading process. What is happening is you are creating multiple object and loading an image into a new object every tiem you click the button. unLoadClip() will prevent this from happening.
