# Enterframe to chack value and dispatch event only once

**URL:** <https://forum.kirupa.com/t/enterframe-to-chack-value-and-dispatch-event-only-once/322039>\
**Category:** Uncategorized\
**Created:** [May 8, 2011, 5:48pm UTC](https://forum.kirupa.com/t/enterframe-to-chack-value-and-dispatch-event-only-once/322039 "2011-05-08T17:48:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bonassus](https://avatars.discourse-cdn.com/v4/letter/b/ea5d25/32.png) [@bonassus](https://forum.kirupa.com/u/bonassus)\
**Post date:** [May 8, 2011, 5:48pm UTC](https://forum.kirupa.com/t/enterframe-to-chack-value-and-dispatch-event-only-once/322039/1 "2011-05-08T17:48:10Z")

</div>

I’m using greensocks MP3Loader to play IntroMp3. I want to dispatch a custom event when the value of the MP3Loader.soundTime property is 3 (3seconds). I’ve done it with an enter frame event. the problem is that it dispatches the event more then one time. what is the better way to check that the MP3Loader.soundTime property is == to 3 and dispatch my event only one time?

Suggestions very much appreciated.

```auto
IntroMp3.playSound();
            
addEventListener(Event.ENTER_FRAME,myFunction);

function myFunction(event:Event) {
addEventListener( CustomEvents.IntroSound, firstMenuOpen, false, 0, true );
            
if(IntroMp3.soundTime >= 3 && IntroMp3.soundTime < 3.1)
{
   dispatchEvent( new CustomEvents( CustomEvents.IntroSound ) );
}
}

```
