BMI を計算して数値にラベルを設定しようとしていますが、数値ではなく "NaN" を返し続けます。
完全なコード:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="BMI Calculator">
<fx:Script>
<![CDATA[
public var weightnum:Number;
public var heightnum:Number;
public var resultvar:Number;
protected function button1_clickHandler():void
{
weightnum = Number(weightvar);
heightnum = Number(heightvar);
resultvar = weightnum * 4.4 / (heightnum * heightnum);
resultstr.text = resultvar.toString();
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Label left="30" top="30" text="Your Weight (lbs)"/>
<s:TextInput id="weightvar" restrict="0-9" x="30" y="53" width="80%"/>
<s:Label x="30" y="104" text="Your Height (feet)"/>
<s:TextInput id="heightvar" restrict="0-9" x="30" y="127" width="80%"/>
<s:Button x="30" y="202" label="Calculate" click="button1_clickHandler()"/>
<s:Label id="resultstr" x="30" y="253" text="" />