add variables into one

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Frugoo Scape
    New Member
    • Oct 2006
    • 34

    add variables into one

    I am trying to add variables into one.
    var a:Number =1;
    var b:Number =2;


    trace(a+b);

    Then ill get 11. I know its adding the numbers up as strings. if i did
    trace(a-b); then i would get 0. Do you know how i can add them together?
  • Frugoo Scape
    New Member
    • Oct 2006
    • 34

    #2
    never mind i used number(b) + number(c)

    Comment

    • bno
      New Member
      • Nov 2006
      • 8

      #3
      If you are concatenating the strings "1" and "2" and coming up with "11" you should worry.

      you could of simply declared a var c e.g....

      Code:
      var a:Number = 1
      var b:Number = 2
      var c:Number = a + b
      trace(c)

      Comment

      Working...