# AS2 Sound player / \*I'm tired\*

**URL:** <https://forum.kirupa.com/t/as2-sound-player-im-tired/267780>\
**Category:** flash\
**Created:** [August 5, 2008, 5:08pm UTC](https://forum.kirupa.com/t/as2-sound-player-im-tired/267780 "2008-08-05T17:08:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stereosushi](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@stereosushi](https://forum.kirupa.com/u/stereosushi)\
**Post date:** [August 5, 2008, 5:08pm UTC](https://forum.kirupa.com/t/as2-sound-player-im-tired/267780/1 "2008-08-05T17:08:31Z")

</div>

I done some debug.  
I found that,

Script calculates the timebar position correct in the first song, if i select next song script continues to calculate from last timebar position.

So I have to reset the Tpercent variable for next and prev song  
Here is my time calculate function. I’ll be really really glad if someone give me a clue!  
Cause i really tired and i stuck.

```auto

function calculateTimeBar(k)
{
    
timeBar._xscale = 0;
timeBar.onEnterFrame = function() 
    {
  
    totaltime = Math.floor(this._parent.sndTrack.duration/1000);
    ongoingtime = Math.floor(this._parent.sndTrack.position/1000);
    
    Tpercent = Math.floor(ongoingtime / totaltime * 100);
    timeBar._xscale = Tpercent;
    

    }
    
}

```
