# Multiple OnEnterFrame functions

**URL:** https://forum.kirupa.com/t/multiple-onenterframe-functions/17032
**Category:** flash
**Created:** [March 31, 2003, 5:56pm UTC](https://forum.kirupa.com/t/multiple-onenterframe-functions/17032 "2003-03-31T17:56:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![alig](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@alig](https://forum.kirupa.com/u/alig)
#### Post date: [March 31, 2003, 5:56pm UTC](https://forum.kirupa.com/t/multiple-onenterframe-functions/17032/1 "2003-03-31T17:56:27Z")

</div>

I have a series of functions that i want to add to a movie clip through the OnEnterFrame command, however i cant get more than one to run at the same time. Is it possible to have more than one going when u are dynamically creating them?

Thanks

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 31, 2003, 6:08pm UTC](https://forum.kirupa.com/t/multiple-onenterframe-functions/17032/2 "2003-03-31T18:08:39Z")

</div>

yes it’s possible but make sure the functions are created before triggering them!  
and it will trigger them ina specific order!  
eg  
onClipEvent(enterFrame) {  
function1();  
function2();  
function3();  
}

it will trigger them in this order: first function1 then the second and then the third. starting from the top… so make sure the action for triggering the function is not somewhere above the function itself!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 31, 2003, 6:16pm UTC](https://forum.kirupa.com/t/multiple-onenterframe-functions/17032/3 "2003-03-31T18:16:21Z")

</div>

sorry, i dont think i explained what i meant properly, which would help i know!

Im setting the functions up at the start of the movie in a frame script, in this case its two functions, one for the \_x and one for the \_y location of a movieclip. Then at a given moment i send both these functions new co-ordinates and the functions ‘create’ OnEnterFrame scripts onto the named movieclip which then runs the scripts in the functions. The problem is that the second function, \_y replaces the \_x script. One OnEnterFrame overides the other.

I guess basically i want away of just adding scripts to the OnEnterFrame rather than assigning them from scratch.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [March 31, 2003, 6:59pm UTC](https://forum.kirupa.com/t/multiple-onenterframe-functions/17032/4 "2003-03-31T18:59:38Z")

</div>

so you’re saying that you have something like this?

```auto
function1 = function() {
this.onEnterFrame = function() {
statement(s);
}
}
function2 = function() {
this.onEnterFrame = function() {
statement(s);
}
}
myMovieClip.function1();
myMovieClip.function2();

```

if so… you can’t. like you said, the onEnterFrame handler created in function1 will be replaced by the onEnterFrame handler created in function2 :-\

syko is right. you’d need to do something like this:

```auto
function1 = function() {
statement(s);
}
function2 = function() {
statement(s);
}
myMovieClip.onEnterFrame = function() {
this.function1();
this.function2();
}

```

😉
