# setTimeout? How does this work?

**URL:** <https://forum.kirupa.com/t/settimeout-how-does-this-work/281063>\
**Category:** flash\
**Created:** [February 4, 2009, 3:07pm UTC](https://forum.kirupa.com/t/settimeout-how-does-this-work/281063 "2009-02-04T15:07:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skarab](https://avatars.discourse-cdn.com/v4/letter/s/ba8739/32.png) [@Skarab](https://forum.kirupa.com/u/Skarab)\
**Post date:** [February 4, 2009, 3:07pm UTC](https://forum.kirupa.com/t/settimeout-how-does-this-work/281063/1 "2009-02-04T15:07:07Z")

</div>

I am trying to get a handle on the setTimeout command and I can’t seem to get it to function at all. As a test I set up a simple movie where two objects fade in, one after the other. But whatever I try, they both fade in together. Here’s the code I’ve got so far

```auto

_global.setTimeout()

stop();

onLoad = function(){
    box1_mc._alpha = 0;
    box2_mc._alpha = 0;
    };

    function firstFade():Void{
    box1_mc._alpha = box1_mc._alpha + 5;    
    };

    function secondFade():Void{
    box2_mc._alpha = box2_mc._alpha + 5;
    };

onEnterFrame = function(){        
        firstFade();
        function timeDelay(){
        var intervalID:Number = setTimeout(this, secondFade, 3000);
        };
        secondFade();
};

clearTimeout(timeDelay);

```

I also tried setInterval but I’m doing something wrong, just can’t see what. Any help appreciated!
