
I found an old AS1 BMI Calculator and I’m trying to convert it to AS3. Anyone out there that can help me look at this? I’ve attached the AS1 FLA. I know that I need to replace the Label, TextInput and Button components with standard inputText fields, buttons and text…
import mx.controls.*;
var txtWeight:TextInput;
var txtFeet:TextInput;
var txtInches:TextInput;
var btnCalculate:Button
var totalHeight:Number;
var totalHeightx2:Number;
var txtError;
var myBmi;
var bmi:Number;
var oPbAddListener:Object = new Object;
oPbAddListener.click = function()
{
var weight = txtWeight.text;
var feet = txtFeet.text;
var inches = txtInches.text;
//trace("got to validation");
if(txtWeight.text == "" || txtFeet.text == "" || txtInches.text == "")
{
txtError.text = "Complete All Fields";
}
else {
txtError.text = "";
totalHeight = (Number(feet) * 12) + Number(inches);
totalHeightx2 = Number(totalHeight) * Number(totalHeight);
bmi = (Number(weight) / totalHeightx2) * 703;
myBmi.text = bmi;
}
}
btnCalculate.addEventListener("click",oPbAddListener);
Thanks.
If you would like to make a comment, please fill out the form below.
Recent Comments