3 Replies Latest reply on Jul 26, 2007 12:51 AM by Greg Dove

    Square function

    ScuffyScouty
      I am currently working on a calculator and I have the following code. Could anyone please help me to determine the code needed to calculate the square value.

      equalbutton.onRelease = function() //calculate the whole sum
      {
      myArray.push(Number(displaybox.text));
      var ans = myArray[0]
      trace(myArray)

      for (var i:Number = 0; i < myArray.length; i ++)
      {
      if (myArray == "+")
      {
      ans += myArray[i+1]; //plus function
      }
      else if (myArray
      == "-")
      {
      ans -= myArray[i+1]; //minus function
      }
      else if (myArray == "*")
      {
      ans *= myArray[i+1]; //multply function
      }
      else if (myArray
      == "/")
      {
      ans /= myArray[i+1]; //divide function
      }
      else if (myArray == "^2")
      {
      //here for square function
      }
      }
      displaybox.text = ans;
      return ans;
      }

      Thanks