PDA

View Full Version : Math script for AS3 (easy)


Kalutz
05-18-2011, 08:50 AM
Hello! ;)

I've just begun with Adobe as3, and I would need some easy help by you guys.
I'm going to do an alcometer, where I write numbers in two input-text boxes. Then they're going to multiply with each others and then divide with 40 and the product should come up in a new text box. (Dynamic-text box)

At the moment I got something like this:

math_btn.addEventListener(MouseEvent.CLICK, calculate);
function calculate(event:MouseEvent):void

{
result_txt.text=String(Number(capacity_txt) * Number(percentage_txt) / 40)
}


math_btn = the button where I click to use the function calculate.
capacity_txt = one of the input text boxes.
percentage_txt = the other input text box.
result_txt = the dynamic text box, where the result should come up.


Please help me :)

GordonG
05-18-2011, 12:17 PM
it looks like you have it all. What's the problem?

brettbeatty
05-18-2011, 12:27 PM
Keep in mind that the variables ending in "_txt" are not Strings, they appear to be input text boxes. To get the String inside, make sure to use their "text" property.
result_txt.text = String( Number( capacity_txt.text ) * Number( percentage_txt.text ) / 40 );

Kalutz
05-18-2011, 01:16 PM
[QUOTE=brettbeatty;1078333]Keep in mind that the variables ending in "_txt" are not Strings, they appear to be input text boxes. To get the String inside, make sure to use their "text" property.

Thanks alot mate, now it's working fine :)
Just needed ".text" as you said