FMX2004::30 sec timer prob

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]

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]

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…