Affichage de temps


/ Published in: ActionScript 3
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.