Copy link to clipboard
Copied
I know this question has been asked many time but the error still occurs.
i'm not using any tlf text fields..all are classic.
here's my code:
import fl.controls.RadioButtonGroup;
import flash.events.MouseEvent;
import fl.controls.RadioButton;
var radioMember:RadioButtonGroup = new RadioButtonGroup ("Maths Function");
male.group = radioMember;
female.group = radioMember;
btn_calculate1.addEventListener(MouseEvent.CLICK,Bmr_calculator);
function Bmr_calculator(event:MouseEvent):void
{
if(radioMember.selection == null)
{
display1.text ="Select your gender";
return;
}
if (age1.text == "")
{
display1.text ="Enter numeric value in text box";
return;
}
if (weight1.text == "")
{
display1.text ="Enter numeric value in text box";
return;
}
if (height1.text == "")
{
display1.text ="Enter numeric value in text box";
return;
}
/*if (radioMember.selection == "Male")
{
var adds = (10 * (weight1.text)) + (6.25*(height1.text)) - (5*(age1.text)) + 5;
result1.text = String(adds);
display1.text ="";
}
if (radioMember.selection == "Female")
{
var adds:Number = Number (weight1.text) + (height1.text) - (age1.text);
result1.text = String(adds);
display1.text ="";
}*/
}
notice that last part of the code is commented. when i run the code, it works well...but when I remove the comment and run it, the output becomes glitchy and the error , ReferenceError: Error #1065: Variable TCMText is not defined. comes out.
in addition to following ned's suggestion, this needs to be fixed:
var adds = (10 * (weight1.text)) + (6.25*(height1.text)) - (5*(age1.text)) + 5;
should be
var adds = (10 * Number(weight1.text)) + (6.25*Number(height1.text)) - (5*Number(age1.text)) + 5;
and
var adds:Number = Number (weight1.text) + (height1.text) - (age1.text);
should be
var adds:Number = Number (weight1.text) + Number(height1.text) - Number(age1.text);
Copy link to clipboard
Copied
Make sure you have a radio button moved into your library as well as any other components you might be using.
Copy link to clipboard
Copied
in addition to following ned's suggestion, this needs to be fixed:
var adds = (10 * (weight1.text)) + (6.25*(height1.text)) - (5*(age1.text)) + 5;
should be
var adds = (10 * Number(weight1.text)) + (6.25*Number(height1.text)) - (5*Number(age1.text)) + 5;
and
var adds:Number = Number (weight1.text) + (height1.text) - (age1.text);
should be
var adds:Number = Number (weight1.text) + Number(height1.text) - Number(age1.text);
Copy link to clipboard
Copied
my mistake! but thank you very much!
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now