# Call function within a onEnterFrame

**URL:** <https://forum.kirupa.com/t/call-function-within-a-onenterframe/171277>\
**Category:** Uncategorized\
**Created:** [December 3, 2005, 4:48pm UTC](https://forum.kirupa.com/t/call-function-within-a-onenterframe/171277 "2005-12-03T16:48:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![blaatorx](https://avatars.discourse-cdn.com/v4/letter/b/f17d59/32.png) [@blaatorx](https://forum.kirupa.com/u/blaatorx)\
**Post date:** [December 3, 2005, 4:48pm UTC](https://forum.kirupa.com/t/call-function-within-a-onenterframe/171277/1 "2005-12-03T16:48:52Z")

</div>

peepz,

i want to call a funtion once within a onEnterFrame, butthe problem is that the onEnterFrame needs to go on and execute the function only once…(if its between the desired x positions (see script below))

my code

```auto

onClipEvent(enterFrame)
{
 if(this._x < -150 && this._x > -1600)
 {
  //execute once!
  fadeIn()
 }
 else{
  //execute once!
  fadeOut()
 }
 this._x = (this._parent.mcBG._x * 1.4)-1950
 this._y = (this._parent.mcBG._y * 1.8)-160
}

```

hope u can help…  
thanks already!
