A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Number formatting

  1. #1
    Junior Member
    Join Date
    Jul 2001
    Posts
    7

    Number formatting

    I'm trying to build an mp3 player and want to format the song.position. What do you do to format numbers in flash so that they have the same number of decimal places?

    Thanks!

    Dan

  2. #2
    FK Slacker
    Join Date
    Jun 2000
    Location
    vancouver
    Posts
    3,208
    Multiply by 100 (for 2 decimal places) to move the decimal to the right, then round it to get rid of the rest or the number, then divide by 100 to move the decimal back to the left...
    code:

    var num=5.2346223;
    var temp=Math.round(num*100);
    var formattedNum=temp/100;
    trace(formattedNum);



    HTH,

    K.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center