# Set Interval Help Plz

**URL:** https://forum.kirupa.com/t/set-interval-help-plz/118668
**Category:** Uncategorized
**Created:** [August 7, 2004, 11:40pm UTC](https://forum.kirupa.com/t/set-interval-help-plz/118668 "2004-08-07T23:40:44Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![HelpAccount](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@HelpAccount](https://forum.kirupa.com/u/HelpAccount)
#### Post date: [August 7, 2004, 11:40pm UTC](https://forum.kirupa.com/t/set-interval-help-plz/118668/1 "2004-08-07T23:40:44Z")

</div>

Hello,

```
 I have an _mc that fades is and then fades out. I want to pause the _mc at frames 1, 25, and 50 of the _mc's timeline and then have it start all over again. I have the following code on the first frame of the _mc :

```

stop();  
function timer(){  
trace(“5 seconds has passed…going to next scene”);  
myHome.bigsun.play();  
clearInterval(timeout);  
};  
timeOut = setInterval(timer, 5000);

and then on frames 25 and 50 i have:

stop();  
timeOut = setInterval(timer, 10000);

The \_mc is on the main timeline. The problem is that the \_mc plays fine with the pauses the first time but then as the \_mc continues to loop, the pauses dont last as long as they are set to in the above code. Its as if the set interval is not obeyed anymore. Could anyone plz comment on this and tell me what i am doind wrong?

---

<div class="post-metadata">

### Author: ![Prophet](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@Prophet](https://forum.kirupa.com/u/Prophet)
#### Post date: [August 8, 2004, 12:08am UTC](https://forum.kirupa.com/t/set-interval-help-plz/118668/2 "2004-08-08T00:08:05Z")

</div>

wel first thing i notice is that

```auto
clearInterval(timeout)

```

does nothing.

```auto
clearInterval(timeOut)

```

on the other hand would work fine - dont forget Action Script is like Java Script in that its case sensitive…

also, i just tried your code with one slight modification, i changed _myHome.bigsun.play()_ to _play()_ which could be your problem… youve stopped the main timeline and you dont start it again, hence you dont reach frames 25 or 50 and therefore you wont change it to an interval of 10 secs…

hope this helps, (only had a quick glance at it ;))

Prophet.

---

<div class="post-metadata">

### Author: ![HelpAccount](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@HelpAccount](https://forum.kirupa.com/u/HelpAccount)
#### Post date: [August 8, 2004, 12:24am UTC](https://forum.kirupa.com/t/set-interval-help-plz/118668/3 "2004-08-08T00:24:19Z")

</div>

> [@Prophet](#):
>
> wel first thing i notice is that
> 
> ```auto
> clearInterval(timeout)
> 
> ```
> 
> does nothing.
> 
> ```auto
> clearInterval(timeOut)
> 
> ```
> 
> on the other hand would work fine - dont forget Action Script is like Java Script in that its case sensitive…
> 
> also, i just tried your code with one slight modification, i changed _myHome.bigsun.play()_ to _play()_ which could be your problem… youve stopped the main timeline and you dont start it again, hence you dont reach frames 25 or 50 and therefore you wont change it to an interval of 10 secs…
> 
> hope this helps, (only had a quick glance at it ;))
> 
> Prophet.

Firat let me say thanks for the reply Prophet. Are you saing the stop(); command in the \_mc is stopping the maintimeline? All commands and their paths are relative to the \_mc. Are they not???

---

<div class="post-metadata">

### Author: ![virusescu](https://avatars.discourse-cdn.com/v4/letter/v/8edcca/32.png) [@virusescu](https://forum.kirupa.com/u/virusescu)
#### Post date: [August 8, 2004, 6:01am UTC](https://forum.kirupa.com/t/set-interval-help-plz/118668/4 "2004-08-08T06:01:36Z")

</div>

as prophet said you must be careful with the names… case sensitive.  
Because you were not using corect clearInterval, every time you accesed the “setInterval(timer, 5000);” it practically created a new repeating every 5seconds “timer” function.  
All worked in parallel and as timed passed, the instances multiplicated and the chances for any one of them that 5 seconds had pass grew proportionaly.  
So basicaly at some moment you had multiple functions shouting at your movie “myHome.bigsun.play();”… thats why the pauses were smaller and smaller.  
Sorry for my english… I hope i solve somehow the mistery 😉

---

<div class="post-metadata">

### Author: ![HelpAccount](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@HelpAccount](https://forum.kirupa.com/u/HelpAccount)
#### Post date: [August 8, 2004, 2:36pm UTC](https://forum.kirupa.com/t/set-interval-help-plz/118668/5 "2004-08-08T14:36:29Z")

</div>

> [@virusescu](#):
>
> as prophet said you must be careful with the names… case sensitive.  
> Because you were not using corect clearInterval, every time you accesed the “setInterval(timer, 5000);” it practically created a new repeating every 5seconds “timer” function.  
> All worked in parallel and as timed passed, the instances multiplicated and the chances for any one of them that 5 seconds had pass grew proportionaly.  
> So basicaly at some moment you had multiple functions shouting at your movie “myHome.bigsun.play();”… thats why the pauses were smaller and smaller.  
> Sorry for my english… I hope i solve somehow the mistery 😉

Thanks Virusescu but I changed and made sure that the “case” were all in order and the same problems are still occuring as stated above.

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [August 8, 2004, 4:21pm UTC](https://forum.kirupa.com/t/set-interval-help-plz/118668/6 "2004-08-08T16:21:07Z")

</div>

> [@HelpAccount](#):
>
> Thanks Virusescu but I changed and made sure that the “case” were all in order and the same problems are still occuring as stated above.

Try putting clearInterval(timeout); on frames 25 and 50.  
I don`t understand how your movie is set up, you say it is situated on the main timeline, yet you are referencing it by myHome.bigsun I would have thought , like Prophet, that play() would be better and i don`t really understand why your code works at all.

---

<div class="post-metadata">

### Author: ![HelpAccount](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@HelpAccount](https://forum.kirupa.com/u/HelpAccount)
#### Post date: [August 8, 2004, 10:09pm UTC](https://forum.kirupa.com/t/set-interval-help-plz/118668/7 "2004-08-08T22:09:26Z")

</div>

> [@stringy](#):
>
> Try putting clearInterval(timeout); on frames 25 and 50.  
> I don`t understand how your movie is set up, you say it is situated on the main timeline, yet you are referencing it by myHome.bigsun I would have thought , like Prophet, that play() would be better and i don`t really understand why your code works at all.

The \_mc is on the main timeline. myHome is the global variable name I gave to the movie. When I use myHome.bigsun.play(); it is with reference to the “bigsun” \_mc on the main timeline.

---

<div class="post-metadata">

### Author: ![Prophet](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@Prophet](https://forum.kirupa.com/u/Prophet)
#### Post date: [August 8, 2004, 11:16pm UTC](https://forum.kirupa.com/t/set-interval-help-plz/118668/8 "2004-08-08T23:16:43Z")

</div>

Stringy its clearInterval(time **O** ut) 😉 lol  
but thats what i thought originally but there is no real point in doing this as you will never reach this frame with the code he has.  
you are stopping the main timeline (the one with 50 frames) and you are only playing a child movieclip. Hence, unless you have some code in this movieclip _myHome.bigsun_ which says

```auto
_root.play()

```

or a \_root.goto action, you will not reach frame 25, let alone 50 to change the setInterval.

hence your problem is not with the setInterval function but rather with basic timeline navigation (and case sensitivity in the clearInterval function 😉 ). seriously, in the function add the following line:

```auto
play()

```

and change the typo in the clearInterval and you should start to see results you wanted to see… trust us!!

Prophet.

PS if you dont believe us or it still doesnt work for some obscure reason, post an fla!

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [August 9, 2004, 5:53am UTC](https://forum.kirupa.com/t/set-interval-help-plz/118668/9 "2004-08-09T05:53:57Z")

</div>

> [@Prophet](#):
>
> Stringy its clearInterval(time **O** ut) 😉 lol  
> but thats what i thought originally but there is no real point in doing this as you will never reach this frame with the code he has.  
> you are stopping the main timeline (the one with 50 frames) and you are only playing a child movieclip. Hence, unless you have some code in this movieclip _myHome.bigsun_ which says
> 
> ```auto
> _root.play()
> 
> ```
> 
> or a \_root.goto action, you will not reach frame 25, let alone 50 to change the setInterval.
> 
> hence your problem is not with the setInterval function but rather with basic timeline navigation (and case sensitivity in the clearInterval function 😉 ). seriously, in the function add the following line:
> 
> ```auto
> play()
> 
> ```
> 
> and change the typo in the clearInterval and you should start to see results you wanted to see… trust us!!
> 
> Prophet.
> 
> PS if you dont believe us or it still doesnt work for some obscure reason, post an fla!

Oops,thats was sloppy especially in light of previous advice.

---

<div class="post-metadata">

### Author: ![HelpAccount](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@HelpAccount](https://forum.kirupa.com/u/HelpAccount)
#### Post date: [August 9, 2004, 1:44pm UTC](https://forum.kirupa.com/t/set-interval-help-plz/118668/10 "2004-08-09T13:44:11Z")

</div>

Hi guys,

```
Here is the .fla's to see whats happening. Hit the home button a few times and just wait and see that the intevals are not working. They work at first but then they do not. I have made sure the "case" are set properly and I have changed the command to play();. Thanks for all your help.
```

---

<div class="post-metadata">

### Author: ![Prophet](https://avatars.discourse-cdn.com/v4/letter/p/838e76/32.png) [@Prophet](https://forum.kirupa.com/u/Prophet)
#### Post date: [August 9, 2004, 5:54pm UTC](https://forum.kirupa.com/t/set-interval-help-plz/118668/11 "2004-08-09T17:54:37Z")

</div>

ok u wernt clearing intervals properly…  
i swapped the button code for this:

```auto
on (press) {
	if(_root.homeLoaded == true){
		_root.load.bigsun.gotoAndStop(1)
	}
	else{
		_root.load.loadMovie("home.swf");
	}
}

```

which will also stop the black flicker you are getting at the start of it 😉

and on the first frame i have

```auto
_root.homeLoaded = true
stop();
clearInterval(timeOut);
function timer(){
	clearInterval(timeOut)
	//trace("5 seconds has passed...going to next frame");
	play();
};
timeOut = setInterval(timer, 5000);

```

minor adjustments but they now work 😉

dont forget FMX processes code line by line… 😉

Prophet.
