dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [F8] Format()

  1. #1
    Software Developer mickm's Avatar
    Join Date
    Sep 2006
    Location
    Kingston [ON]
    Posts
    115

    [F8] Format()

    Is there some kind of Format(Object, "format string") method in flash?

    What I am trying to accomplish is the following;

    Code:
    Var nNumber : Number = 1234567890;
    Var nNumber2 : Number = 7;
    
    trace (format(nNumber, "#,###,###,###,##0"));
    trace (format(nNumber2, "#,###,###,###,##0"));
    output should be:
    Code:
    1,234,567,890
    7
    Anyone know of a way to do this or will i have to write my own function?
    Post you game for free at Gamestack.org. We send the user straight to your website, no iFrames or other leeching methods.

    Please check out Gamestack.org for more information.

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    will i have to write my own function?

    no need to re-invent the wheel -

    Currency Formatting
    This sample includes a function that receives parameters for value,
    number of decimal places, and the character to use as a separator
    in the great-than-zero part of the number, for instance, commas in
    1,000,000.00. If no separator character is specified (comma is default),
    none will be used. If no places are specified, or places is specifed as zero,
    the number will be a rounded integer. This example uses input textfields
    for allowing the user to specify the values, but the function has also been
    built to accept actual numeric values, and includes error trapping.
    Function includes verbose commenting.
    http://canfieldstudios.com/flash5/currfrmt/index.html

  3. #3
    Software Developer mickm's Avatar
    Join Date
    Sep 2006
    Location
    Kingston [ON]
    Posts
    115
    Thanks dog thats exactly what I was looking for.
    Just needed to change it to a function and worked perfectly.
    Post you game for free at Gamestack.org. We send the user straight to your website, no iFrames or other leeching methods.

    Please check out Gamestack.org for more information.

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    you're welcome

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