# Position of mp3 file vs timer event

**URL:** <https://forum.kirupa.com/t/position-of-mp3-file-vs-timer-event/317028>\
**Category:** flash\
**Created:** [December 8, 2010, 10:23am UTC](https://forum.kirupa.com/t/position-of-mp3-file-vs-timer-event/317028 "2010-12-08T10:23:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaxz](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@jaxz](https://forum.kirupa.com/u/jaxz)\
**Post date:** [December 8, 2010, 10:23am UTC](https://forum.kirupa.com/t/position-of-mp3-file-vs-timer-event/317028/1 "2010-12-08T10:23:21Z")

</div>

Hi all I have a media player code that intends to Cross fade files as the one playing comes close to its end (filelength - dt) , and start playback of the next one just before the end. To get it right (optimize var dt) I tried to trace the position of the file. But get impossible values - the position seems to shift forward as time passes…

```auto
function LoadNext_T(e:Event = null):void // set next theme
{
    if (A_play) {
     nextA = new Sound();
     nextA.addEventListener(Event.COMPLETE, PlayNextTheme,false, 0, true);
     nextA.load(gettheme);      
    }
    else {
      nextB = new Sound();
      nextB.addEventListener(Event.COMPLETE, PlayNextTheme,false, 0, true);
      nextB.load(gettheme);      
    }   
 if( (SC_A != null ) && SC_B != null)) {Xfade();}
}

function PlayNextTheme(e:Event):void    
{
        if (A_play) {
            ThemeLong = nextA.length; 
            SC_A.soundTransform = volumeform_AB;                                                            
        }
        else {
            ThemeLong = nextB.length; 
            SC_B.soundTransform = volumeform_AB;            
        }
    var timer_AB: Timer = new Timer(ThemeLong - dt,1);  
    if (special conditions met) {
timer_AB.addEventListener(TimerEvent.TIMER, LoadNext_T,false, 0, true); 
        timer_AB.start();    
}

function Xfade(): void
{
trace("SC_A pos = " , SC_A.position;);
trace("SC_B pos = ", SC_B.position;);
// start of some crossfade code //
}

```

WIth code as above - I get the surprising result that the positions traced in Xfade are LOWER than the Event argument ThemeLong -dt; that seems very odd, running through code usually takes time ??  
Eg, Themelong is 20000ms dt is 500 ms I get outputs like 19345 etc, that is shorter than the supposed position at which the timer timer\_AB is instructed to call the next Load function.  
??  
PLS advice,  
Jaxz
