# Executing a function in onEnterFrame

**URL:** <https://forum.kirupa.com/t/executing-a-function-in-onenterframe/25869>\
**Category:** Uncategorized\
**Created:** [July 17, 2003, 5:41am UTC](https://forum.kirupa.com/t/executing-a-function-in-onenterframe/25869 "2003-07-17T05:41:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![javadi82](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@javadi82](https://forum.kirupa.com/u/javadi82)\
**Post date:** [July 17, 2003, 5:41am UTC](https://forum.kirupa.com/t/executing-a-function-in-onenterframe/25869/1 "2003-07-17T05:41:00Z")

</div>

A function has to “run”(execute) inside the onEnterFrame event method but the function does not seem to run when called. Why?

Example:

\_root.onEnterFrame()=function(){  
if(something==true){  
performFunction();  
}  
}

function performFunction()  
{  
}

---

<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:** [July 17, 2003, 5:54am UTC](https://forum.kirupa.com/t/executing-a-function-in-onenterframe/25869/2 "2003-07-17T05:54:06Z")

</div>

shouldn’t it be

this.onEnterFrame = function() {

or maybe

\_root.onEnterFrame = function() {

There shouldn’t be the () after the onenterframe…

---

<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:** [July 17, 2003, 7:00am UTC](https://forum.kirupa.com/t/executing-a-function-in-onenterframe/25869/3 "2003-07-17T07:00:19Z")

</div>

sorry that was a typo.there is actually no “()” in the code.

---

<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:** [July 17, 2003, 8:46am UTC](https://forum.kirupa.com/t/executing-a-function-in-onenterframe/25869/4 "2003-07-17T08:46:11Z")

</div>

actually,there is no mistake in the code. but you can use  
[AS]if(something){  
}[/AS]  
instead of  
[AS]  
if(something==true){  
}[/AS]  
…  
and u can place

function performFunction()  
{  
}

before

\_root.onEnterFrame()=function(){  
if(something==true){  
performFunction();  
}  
}

e.s.x.s
