Flex 4.6 Formatting a Binded Label with Decimal Places

Posted on 2012-09-14
Last Modified: 2012-09-17
In the following example I have a spark label that is binded to the average value of 4 other Numeric Steppers.  This work fine apart from (depending on the values) i'm getting results with too many decimal place's.

<s:Label text="{(numericStepper1.value + numericStepper2.value + numericStepper3.value + numericStepper4.value)/4}"/>

Open in new window

For example i'm getting:

Instead I want:
Question by:RenAndStimpy
    LVL 81

    Accepted Solution


    Author Comment

    Yep, toFixed(2) did the trick.

    s:Label text="{((numericStepper1.value + numericStepper2.value + numericStepper3.value + numericStepper4.value)/4).toFixed(2)}"/>

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
    It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
    The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now