A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Convert integers to “US numeric format”?

  1. #1
    Dynamic Systems, Inc. mikaelian's Avatar
    Join Date
    Oct 2000
    Location
    DySyst.com
    Posts
    1,383

    Convert integers to “US numeric format”?

    Dear Falshkitters,

    Will somebody be able to help me to find a script that allows to convert integers to “US numeric format”? That is, it converts 1000000 to 1.000.000, it converts 1200 to 1.200, etc.

    Thank you very much in advance for your help.

    Vahagn
    Dynamic Systems
    Professional Web Development Solutions!
    www.DySyst.com

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Hi,

    add the following to a frame at the start of your movie

    code:

    Number.prototype.format = function() {
    var str = this.toString();
    var lp = (str.length % 3 != 0) ? str.length % 3 : 3;
    var formatStr = str.substr(0, lp);
    for (var i = lp; i < str.length; i += 3) {
    formatStr += "," + str.substr(i, 3);
    }
    return formatStr;
    };



    now in your movie you can use something like this,

    var myNum = 7363275;
    var myFormatedNum = myNum.format()
    trace(myFormatedNum); // displays 7,363,275
    Last edited by catbert303; 10-28-2003 at 12:23 PM.

  3. #3
    Dynamic Systems, Inc. mikaelian's Avatar
    Join Date
    Oct 2000
    Location
    DySyst.com
    Posts
    1,383
    Dear catbert303,

    Thank you very much for your message and your help. Yes, that code was exactly what I needed. it works.

    Thank you!
    :-)

    Vahagn
    Dynamic Systems
    Professional Web Development Solutions!
    www.DySyst.com

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