3 Replies Latest reply on Aug 3, 2006 7:19 AM by DazFaz

    To put symbol in Array

    Markéta
      I try to put in Array this: "." symbol in Actionscript.
      I have Number : 1222333, by after I have put him in Array.
      For example: I have see 1.222.333 humans.
      I need to see 1.222.333.
      Can you help me, please?
        • 1. Re: To put symbol in Array
          DazFaz Level 1
          Its not that clear what you want to acheive
          • 2. Re: To put symbol in Array
            Markéta Level 1
            For example: I have e-shop, wen total number of price is a long number, bat is illegible,
            because there is 9 number: 123456789,
            I have dynamic text, where a Iike to have this: 123.456.789,
            I don´t now, how I can to give spot between every 3 numbers.

            I have variable number. This number I put him in Array.
            For example:

            var price = 555000;
            var chunk = 10000;
            totalchunk= price*chunk;
            totalprice= new Array();
            totalprice.push ( "The price is : " + price + " . Total is: " + totalchunk );

            In dynamic text you can see: The price is 5000. Total is 5550000000

            But I like to see: The price is 5.000. Total is 5.550.000.000

            I don´t now, how I can to give spot between every 3 numbers.
            • 3. To put symbol in Array
              DazFaz Level 1
              Im pretty sure there is a more effecient way of doing this but Ive put this together pretty quick.


              addPointsToNumber = function (myNumber:String,symbol:String) {
              var myVerLargeNumber:String = myNumber;
              var myNumberArray:Array = myVerLargeNumber.split ("");
              var reversedArray:Array = new Array ();
              myCounter = myNumberArray.length - 1;
              for (var i:Number = 0; i < myNumberArray.length; i++) {
              reversedArray = myNumberArray[myCounter - i];
              }
              for (var i:Number = 0; i < reversedArray.length; i++) {
              if (i / 4 == Math.round (i / 4)) {
              reversedArray.splice (i, 0, symbol);
              }
              }
              var finalArray:Array = new Array ();
              myCounter = reversedArray.length - 1;
              for (var i:Number = 0; i < reversedArray.length; i++) {
              finalArray
              = reversedArray[myCounter - i];
              }
              finalArray.pop ();
              var myFinalString:String = new String ();
              for (var i:Number = 0; i < finalArray.length; i++) {
              myFinalString += finalArray ;
              }
              return myFinalString;
              };
              trace(addPointsToNumber("5555000000000000000000000000000","."));

              Hope it helps