Posted By

ions on 05/10/11


Tagged

time actionscript as3 formatage temps


Versions (?)

Affichage de temps


 / Published in: ActionScript 3
 

Utile pour formater l'affichage d'un compteur de temps (player video, player mp3, …)

  1. function timeCode(theTime:uint):String
  2. {
  3. var theMin:uint = Math.floor(theTime / 60);
  4. var theSec:uint = theTime % 60;
  5. var tcString:String = "";
  6.  
  7. if (theMin < 10) {
  8. tcString += "0";
  9. }
  10. if (theMin >= 1) {
  11. tcString += theMin.toString();
  12. }else {
  13. tcString += "0";
  14. }
  15.  
  16. tcString += ":";
  17. if (theSec < 10) {
  18. tcString += "0";
  19. tcString += theSec.toString();
  20. }else {
  21. tcString += theSec.toString();
  22. }
  23.  
  24. return tcString;
  25. }

Report this snippet  

You need to login to post a comment.