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 14 | 1067: Implicit coercion of a value of type flash.text:TextField to an unrelated type String. |
| Scene 1, Layer 'Actions', Frame 1, Line 15 | 1067: Implicit coercion of a value of type flash.text:TextField to an unrelated type String. |
| Scene 1, Layer 'Actions', Frame 1, Line 16 | 1067: 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
If you look at the tutorial I think you will see that you are using "txt" where "text" is required. "text" is a property of a textfield, identifying the text that the textfield holds. I don't know if you are doing something where the num1 object contains another object named txt, but I think my first sentence catches the problem.
North America
Europe, Middle East and Africa
Asia Pacific