# Code structure

**URL:** <https://forum.kirupa.com/t/code-structure/187940>\
**Category:** Uncategorized\
**Created:** [May 3, 2006, 10:10am UTC](https://forum.kirupa.com/t/code-structure/187940 "2006-05-03T10:10:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![oaki](https://avatars.discourse-cdn.com/v4/letter/o/7993a0/32.png) [@oaki](https://forum.kirupa.com/u/oaki)\
**Post date:** [May 3, 2006, 10:10am UTC](https://forum.kirupa.com/t/code-structure/187940/1 "2006-05-03T10:10:03Z")

</div>

Hi!

I’ve written a couple of functions for a website and now I wanna put everything together.  
What I want to do is for example play “function1” first and when it’s done, “function2” should run. When “function2” is done, “function3” starts and so on.

What is the best way to do that?

So far I’ve done something like this:

```auto

function1();

function function1() {
onEnterFrame = function() {
if (i<100) { 
i++;
}
else {
function2();
}
}

}

```

but if you’ve got 20 functions it gets way too complex…

Is there an easier way to control functions?
