3 Replies Latest reply on Nov 9, 2006 12:11 PM by Xak_tre

    FLV timer

    Xak_tre
      I need an easy way to convert the milliseconds from playheadTime and totalTime of an FLV clip into minutes and seconds.

      I am currently using:
      Math.floor (_parent.timX.playheadTime / 60)
      (Math.floor (_parent.timX.playheadTime % 60)/100)
      Math.floor (_parent.timX.totalTime / 60)
      (Math.floor (_parent.timX.totalTime % 60)/100)

      Then using an array to concat the results. It works somewhat but I think it is a bit sketchy. Is there and easy way to do this using one of the Date.functions?

      Thanks,

      _Xak
        • 1. Re: FLV timer
          arunbe Level 1
          Hi,


          Use this function

          function changeFormat(timeString:String) {
          var duration = timeString.split(".")[0];
          if (duration<60) {
          hours = 0;
          minutes = 0;
          seconds = duration;
          } else {
          seconds = duration%60;
          minutes = Math.floor(duration/60);
          hours = Math.floor(duration/3600);
          }
          var timeStamp:String = setWithDecimal(minutes.toString())+":"+setWithDecimal(seconds.toString());
          return (timeStamp);
          }
          function setWithDecimal(val:String) {
          (val.length<2) ? val="0"+val : val=val;
          if (val != undefined) {
          return (val);
          }
          }



          You just pass the time to this function changeFormat() like,

          changeFormat(netStream_ns.time);

          It will return you a string like "00:10" ( 10 seconds)


          Cool :)



          Arun
          • 2. Re: FLV timer
            arunbe Level 1
            Sorry, i forgot you to tell onething
            you have to pass the time as string
            like this

            changeFormat(netStream_ns.time.toString());


            Cool.... :)
            • 3. Re: FLV timer
              Xak_tre Level 1
              Thanks, I came up with a diiferent solution. But yours works well also.

              _Xak