1 Reply Latest reply on Oct 23, 2007 12:02 PM by Handycam

    Adding results

    GeorgeWS Level 1
      I have 2 results:

      <mx:Label id="lblStringResult" text="{sResult}" width="50%"/>
      <mx:Label id="lblStringResult2" text="{sResult2}" width="50%"/>

      How can I add the sResult to the sResult2 and make...:

      <mx:Label id="lblStringResult3" text="{sResult3}" width="50%"/>

      if sResult is 6 and sResult 5, I want sResult3 to be 11

      Thanks

      George
        • 1. Re: Adding results
          Handycam Level 1
          The two variables need to be numbers to add them.

          I would try to start them out as numbers and keep them that way until you need to show them in text.

          If you don't need to bind to the data, how about:


          private var sResult:Number;
          private var sResult2: Number;
          private var sResult3:Number;

          function addThoseNumbers() : void {
          lblStringResult.text = sResult.toString();
          lblStringResult2.text = sResult2.toString();
          sResult3 = sResult + sResult2;
          lblStringResult3.text = sResult3.toString();
          }

          And having the text objects text=""