3 Replies Latest reply: Sep 7, 2012 8:58 AM by Ned Murphy RSS

    Flash rookie needs help with error messages when making simple calculator in AS3.

    Mrbo0m Community Member

      I am trying to make a simple calculator I have been following this guide:

       

      http://www.youtube.com/watch?v=5k3h37YKZJI

       

      this is my code.

       

      var Hnum:String;

      var PCnum:String;

      var calc:Number = 25;

      var Total:String;

       

      num1.restrict = "0-9";

      num2.restrict = "0-9";

       

      Est_btn.addEventListener(MouseEvent.CLICK, calculate);

      function calculate(event:MouseEvent):void{

         

          Hnum = num1.txt;

          PCnum = num2.txt;

          Total = parseInt(Hnum) * calc;

          Total.toString();

          Total_txt.text = String(Total);

      }

       

      I am getting these 3 errors:

       

      Scene 1, Layer 'Actions', Frame 1, Line 141067: Implicit coercion of a value of type flash.text:TextField to an unrelated type String.

       

      Scene 1, Layer 'Actions', Frame 1, Line 151067: Implicit coercion of a value of type flash.text:TextField to an unrelated type String.

       

      Scene 1, Layer 'Actions', Frame 1, Line 161067: Implicit coercion of a value of type Number to an unrelated type String.

       

       

      I have two input text boxs named num1 and num2 and then one dynamic text box named Total_txt.

       

      This should be so simple I really don't know what im doing wrong?

       

      Any help would be really appreciated.

       

      MrB