2 Replies Latest reply on Apr 12, 2010 1:37 PM by rcanulla

    Formatting a number for commas

    rcanulla

      Does anyone know how I would format a number to add in commas?

       

      Any help if much appreciated!

        • 1. Re: Formatting a number for commas
          Peter deHaan Level 4

          Use the NumberFormatter class:

           

          <?xml version="1.0" encoding="utf-8"?>
          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                         xmlns:s="library://ns.adobe.com/flex/spark"
                         xmlns:mx="library://ns.adobe.com/flex/mx">
              
              <fx:Declarations>
                  <mx:NumberFormatter id="numFmttr" precision="2" useThousandsSeparator="true" />
              </fx:Declarations>
              
              <s:Label text="{numFmttr.format(1234567890)}" x="20" y="20" />
              
          </s:Application>
          

           

          Peter

          • 2. Re: Formatting a number for commas
            rcanulla Level 1

            Thanks Peter. Not sure how I missed that one.