1 person found this helpful
You may find all you need to solve this by going thru the following nearby posting:
Also, you don't need to waste an enterframe on this. You can use the onChanged method of a textfield to trigger a function to perform the calculation whenever the values in the textfields change.
Are you using the "variable" field for referencing the text field? Avoid using it if you are. Use the "instance name" instead and you can access the text with the ".text" property. Then as Ned mentioned you can use the onChanged handler to update the text field. First make sure all your text fields' behavior are set to "Single line" in the property inspector and set the instance names (i.e. txtScore1, txtScore2, txtTotal) then you can use this code:
txtScore1.onChanged = Delegate.create(this, onInputChange);
txtScore2.onChanged = Delegate.create(this, onInputChange);
//trace("TextField that Changed: " + txtField);
var nScore1:Number = int(txtScore1.text);
var nScore2:Number = int(txtScore2.text);
var nTotal:Number = nScore1 + nScore2;
txtTotal.text = nTotal.toString(); //Convert number to string;
Thank you Ned and Harry! both of your solutions worked great!
You're welcome. We're always here to help.