# Timed actions using sound object

**URL:** <https://forum.kirupa.com/t/timed-actions-using-sound-object/16327>\
**Category:** Uncategorized\
**Created:** [March 23, 2003, 7:13pm UTC](https://forum.kirupa.com/t/timed-actions-using-sound-object/16327 "2003-03-23T19:13:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mojoNYC](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@mojoNYC](https://forum.kirupa.com/u/mojoNYC)\
**Post date:** [March 23, 2003, 7:13pm UTC](https://forum.kirupa.com/t/timed-actions-using-sound-object/16327/1 "2003-03-23T19:13:11Z")

</div>

hi all-  
i’m using .position with an mp3 sound object to create a timer which i’m using to trigger actions in my main movie:

\_level0.theTime =Math.floor(soundTrack.position/1000);

//on enterframe event

if (theTime==10){  
objectMC.dosomething();  
}

my problem is that the timer code sends multiple instances of the same value, ie. “1,1,1,2,2,2,3,3,3…” etc., which is causing troubles with loading events being triggered more than once–is there a good method for checking or otherwise causing the count to register only once? thanks in advance…  
-mojo

---

<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 23, 2003, 8:36pm UTC](https://forum.kirupa.com/t/timed-actions-using-sound-object/16327/2 "2003-03-23T20:36:12Z")

</div>

use another var like theOldTime, to check if theTime has changed since the last call, if yes, do your check, if no, update theOldTime to current theTime value for next check…makes sense?

---

<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 25, 2003, 3:43am UTC](https://forum.kirupa.com/t/timed-actions-using-sound-object/16327/3 "2003-03-25T03:43:56Z")

</div>

got it- thanks for your help, eyez!  
-mojo
