# Run a function inside a function?

**URL:** <https://forum.kirupa.com/t/run-a-function-inside-a-function/245122>\
**Category:** Uncategorized\
**Created:** [November 26, 2007, 5:12pm UTC](https://forum.kirupa.com/t/run-a-function-inside-a-function/245122 "2007-11-26T17:12:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![th3Phallex](https://avatars.discourse-cdn.com/v4/letter/t/9fc29f/32.png) [@th3Phallex](https://forum.kirupa.com/u/th3Phallex)\
**Post date:** [November 26, 2007, 5:12pm UTC](https://forum.kirupa.com/t/run-a-function-inside-a-function/245122/1 "2007-11-26T17:12:47Z")

</div>

I’m using setInterval to pause between functions, called, “setText1”, “setText2”, etc… I’m using keyframes to determine when to start running the next function, but I know there’s an easier way to do it.

What i’d like to do is just have one keyframe that runs all the functions in order, kind of like this:

```auto

function setText1(){
// do stuff here
 new TimeOut(this, "setText2", 500);
}
setText1();
 
function setText2(){
// do stuff here
 new TimeOut(this, "setText3", 500);
}
setText2();
 
function setText3(){
// do stuff here
 new TimeOut(this, "setText4", 500);
}
setText3();

```

…as you can see, it will run the first function, wait, run the next one, wait, etc…

My question would be: How can I create my function called ‘TimeOut’ that will run whatever function-name is passed to it? Can you run a function within a function??

Please help!
