# FMX2004::30 sec timer prob

**URL:** <https://forum.kirupa.com/t/fmx2004-30-sec-timer-prob/60573>\
**Category:** flash\
**Created:** [August 10, 2004, 9:15pm UTC](https://forum.kirupa.com/t/fmx2004-30-sec-timer-prob/60573 "2004-08-10T21:15:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinB](https://avatars.discourse-cdn.com/v4/letter/k/c0e974/32.png) [@kevinB](https://forum.kirupa.com/u/kevinB)\
**Post date:** [August 10, 2004, 9:15pm UTC](https://forum.kirupa.com/t/fmx2004-30-sec-timer-prob/60573/1 "2004-08-10T21:15:27Z")

</div>

ive done a little media player for my mates website.means i didnt understand the xml and loading audio that way i decided to try another way,which was to load external .swf which contained audio.so ive done this everything working.the problem is i tried to add a timer, so that when the 30 sec sample was done it would go to the next frame which loads a different track.i found a piece of timer code which is

[color=#000000][color=#0000bb] loadMovieNum[/color][color=#007700]([/color][color=#dd0000]“track2.swf”[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700]);  
if ([/color][color=#0000bb]bytes\_loaded [/color][color=#007700]== [/color][color=#0000bb]bytes\_total[/color][color=#007700]) {  
var [/color][color=#0000bb]time [/color][color=#007700]= [/color][color=#0000bb]0[/color][color=#007700];

```
 [/color][color=#0000bb]timer [/color][color=#007700]= function(){ 
     [/color][color=#0000bb]time[/color][color=#007700]++; 
     if([/color][color=#0000bb]time [/color][color=#007700]== [/color][color=#0000bb]30[/color][color=#007700]){ 
         [/color][color=#0000bb]clearInterval[/color][color=#007700]([/color][color=#0000bb]run[/color][color=#007700]); 
         [/color][color=#0000bb]nextFrame[/color][color=#007700](); 
     }; 
 }; 

```

}  
var [/color][color=#0000bb]run [/color][color=#007700]= [/color][color=#0000bb]setInterval[/color][color=#007700]([/color][color=#0000bb]timer[/color][color=#007700], [/color][color=#0000bb]1000[/color][color=#007700]);  
[/color][color=#0000bb]stop[/color]color=#007700;

It all works first time around but when you select the track again then it cuts out 20-25 seconds,I posted this on another forum and was told to put it within a onenterframe statement.but it didnt work :crying: … any ideas thanx…  
[/color][/color]

---

<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:** [August 11, 2004, 4:43am UTC](https://forum.kirupa.com/t/fmx2004-30-sec-timer-prob/60573/2 "2004-08-11T04:43:53Z")

</div>

oooh señor  
you forget to declare the time value at the start…

in first place PUT IT ON AN ENTER FRAME  
and use the getTimer function  
maybe something like this: (repleace just you function code with this and delete the interval)[AS]  
function timer(){  
var timeNow = getTimer();  
this.onEnterFrame = function(){  
if (getTimer()-timeNow==3000){  
nextFrame();  
if(\_currentframe!=\_totalframes){  
timer();  
}  
}  
}  
}  
} [/AS]

---

<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:** [August 11, 2004, 8:44pm UTC](https://forum.kirupa.com/t/fmx2004-30-sec-timer-prob/60573/3 "2004-08-11T20:44:40Z")

</div>

like this…

loadMovieNum(“track6.swf”, 1);  
onEnterFrame = function() {  
function timer(){  
var timeNow = getTimer();  
this.onEnterFrame = function(){  
if (getTimer()-timeNow==3000){  
nextFrame();  
if(\_currentframe!=\_totalframes){  
timer();  
}  
}  
}  
}  
}

is that right or am i totally off course sorry to be a pain…
