A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Displaying decimal numbers? (HELP!)

  1. #1
    Junior Member
    Join Date
    Jan 2002
    Location
    Maine
    Posts
    19

    Displaying decimal numbers? (HELP!)

    I'd be surprised if there wasn't a way to do this, but I haven't been able to figure it out yet:

    I need to be able to diplay the price of something in a dynamic textbox, which should include both dollars and cents. Depending on what you select for "quantity" the price changes dynamically.

    The problem is, if the value of the "price" variable is a number and not a string and there are zeros to the right of the decimal, they are simply and understandably dropped (example: 8.50 is displayed as 8.5). Because the value of price is always the product of the BasePrice times the Quantity, it is a number by default, not a string.

    Is there an actionscript method that allows you to define the number of places to the right of the decimal there should be for a given variable?


    Any suggestions would be appreciate!

    Thanks,
    Shane:confused:

  2. #2
    Senior Member
    Join Date
    May 2001
    Location
    VA
    Posts
    145
    Just write a function that evaluates the number of decimal places after the decimal point, and add a zero, or round as necessary.

    --Andrew
    ---Trmbne2000@hotmail.com
    <---Trmbne2000@hotmail.com--->

  3. #3
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    search is busy at this time, so i'll let you do it.
    There is a post by 'robertpenner' which covers that subject in this forum.
    Lots of very useful functions by Mr Penner
    gparis

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