Search code examples
flashactionscript-2

sum two textinput in flash and show in textfield?


I want to sum two text input and show result in text field.

I use flash and as2.


Solution

  • Do you have any code to post showing effort?

    Here are the things you should look at.

    Validate text field 1 and 2 to ensure that only numbers are entered (look at "restrict").

    Convert your text to numbers (look at "Number()" and perform the math (text3.text = num1 + num2 then output it to another text area.

    Awww heck... Im in a good mood this morning

    private function addFields():void{    
        text3.text = (Number(text1.text) + Number(text2.text)).toString();
    }
    
    <s:textInput id="text1" restrict"0-9"/>
    <s:textInput id="text2" restrict"0-9"/>
    <s:textInput id="text3"/>
    

    Then just add a button with its onClick set to call addFields().

    Next time, post some of the things you have tried and folks will generally be faster and more willing to help. Have a good one.