# Need help with setInterval

**URL:** <https://forum.kirupa.com/t/need-help-with-setinterval/182362>\
**Category:** Uncategorized\
**Created:** [March 17, 2006, 2:00pm UTC](https://forum.kirupa.com/t/need-help-with-setinterval/182362 "2006-03-17T14:00:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![scarlac](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@scarlac](https://forum.kirupa.com/u/scarlac)\
**Post date:** [March 17, 2006, 2:00pm UTC](https://forum.kirupa.com/t/need-help-with-setinterval/182362/1 "2006-03-17T14:00:26Z")

</div>

Hi

I have some problems applying a setInterval. I just wrote some code to create my menu on the stage. I’d like every menu-item to eppear with an interval.

Can some1 help me

Here is my file.

thanx in advance  
scarlac

---

<div class="post-metadata">

**Author:** ![scarlac](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@scarlac](https://forum.kirupa.com/u/scarlac)\
**Post date:** [March 19, 2006, 12:34pm UTC](https://forum.kirupa.com/t/need-help-with-setinterval/182362/2 "2006-03-19T12:34:18Z")

</div>

Hi

Thanx for correcting and adding code to it. I really appreciate. I started a few weeks ago with actionscript and it is going pretty well.

But I have a questions about it.

I don’t understand exactly why you are using that stg variable

Thanx in advance  
scarlac

---

<div class="post-metadata">

**Author:** ![watcher](https://avatars.discourse-cdn.com/v4/letter/w/77aa72/32.png) [@watcher](https://forum.kirupa.com/u/watcher)\
**Post date:** [March 19, 2006, 8:37pm UTC](https://forum.kirupa.com/t/need-help-with-setinterval/182362/3 "2006-03-19T20:37:12Z")

</div>

> [@scarlac](#):
>
> Hi
> 
> Thanx for correcting and adding code to it. I really appreciate. I started a few weeks ago with actionscript and it is going pretty well.
> 
> But I have a questions about it.
> 
> I don’t understand exactly why you are using that stg variable
> 
> Thanx in advance  
> scarlac

The reason i use stg variable is this:

```auto
var stg = this;

var nIntfInMenu = setInterval(fInMenu, nSpdfInMenu);

function fInMenu(){
            trace(this)
}

```

If you run and try to trace previous, you will notice that you lost the refference to .this and it traces [COLOR=Red]undefined[/COLOR]. Also for anything else EXCEPT \_root you get [COLOR=Red]undefined[/COLOR]. Now i think the reason to this is, because [COLOR=SeaGreen]setInterval[/COLOR] function works in different way than any other frame-dependant actionscript. But i am not sure, so anybody please enlighten me :). I am only sure, that i loose the refference to relative paths inside the movie.

Now as mentioned, you can use the absolute addressing: \_root to refference previous, without using variable stg [from stage:P]. But i personally dont like using \_root, because if for ex. i decide once that my .swf file will be preloaded into some other .swf-file [which will become it’s parent and also \_root for everything inside] i would have to manually rewrite the code for its child 😃

Please ask if you didnt get something/i was unclear. Enjoy!
