# \[AS2/CS3\]call function only once in an onEnterFrame

**URL:** <https://forum.kirupa.com/t/as2-cs3-call-function-only-once-in-an-onenterframe/315818>\
**Category:** flash\
**Created:** [November 4, 2010, 11:34pm UTC](https://forum.kirupa.com/t/as2-cs3-call-function-only-once-in-an-onenterframe/315818 "2010-11-04T23:34:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BadBoyMcCoy](https://avatars.discourse-cdn.com/v4/letter/b/bbe5ce/32.png) [@BadBoyMcCoy](https://forum.kirupa.com/u/BadBoyMcCoy)\
**Post date:** [November 4, 2010, 11:34pm UTC](https://forum.kirupa.com/t/as2-cs3-call-function-only-once-in-an-onenterframe/315818/1 "2010-11-04T23:34:31Z")

</div>

OK I’ve been trying to work this out for a while and I think I’m going to have to ask for help.

```auto

function ghostGoUpDown(currentGhost) {
    //do stuff
}

benet.onEnterFrame = function() {
   //do stuff

    if(maze_mc.hitTest(this._x-16,this._y,true)) {
        ghostGoUpDown(benet);
        //do stuff
    }

    if(maze_mc.hitTest(this._x+16,this._y,true)) {
        ghostGoUpDown(benet);
        //do stuff
    }
}

```

How can I change it so that the ghostGoUpDown is only run once each frame the hit test is true? I’m pretty new to as2, sorry if it’s stupid question but at least it’ll be easy to answer! I can post full code if needed.

TIA  
McCoy
