我是ActionSccript 3.0的初学者 . 我做了这个代码工作正常但是当我把数量超过150克时,我在输出中出现错误,错误#1006:值不是函数请帮助 . 介意给我正确的代码?谢谢
//import controls
import fl.controls.RadioButtonGroup;
import flash.events.MouseEvent;
import fl.controls.RadioButton;
// This line makes the button, btnCalculate wait for a mouse click
// When the button is clicked, the determineCost function is called
btnCalculate.addEventListener(MouseEvent.CLICK, determineCost);
// These lines make the textinput and the radioButtons wait for a mouse click
// When these components are clicked, the clearLabels function is called
txtinMass.addEventListener(MouseEvent.CLICK, clearLabels);
// This is the determineCost function
// e:MouseEvent is the click event experienced by the button
// void indicates that the function does not return a value
function determineCost(e:MouseEvent):void
{
// declare the variables
var Mass:uint;
var Letter:RadioButtonGroup = new RadioButtonGroup("Letters");
// put the groups together
FirstRadio.group = Letter;
SecondRadio.group = Letter;
// get the mass from the user
Mass = uint(txtinMass.text);
// determine the cost
if (Mass <= 30 && Letter.selection.label == "First Class")
{
lblCost.text = "0.38";
}
else if (Mass <= 30 && Letter.selection.label == "Second Class")
{
lblCost.text = "0.28";
}
else if (Mass > 30 && Mass <= 50 && Letter.selection.label == "First Class")
{
lblCost.text = "0.55";
}
else if (Mass > 30 && Mass <= 50 && Letter.selection.label == "Second Class")
{
lblCost.text = "0.40";
}
else if (Mass > 50 && Mass <= 100 && Letter.selection.label == "First Class")
{
lblCost.text = "0.73";
}
else if (Mass > 50 && Mass <= 100 && Letter.selection.label == "Second Class")
{
lblCost.text = "0.55";
}
else if (Mass >= 150 && Letter.selection.label == "First Class")
{
lblCost = ((0.73 + 0.24 * Math.floor((Mass - 100) / 50)))();
}
else if (Mass >= 150 && Letter.selection.label == "Second Class")
{
lblCost = ((0.55 + 0.19 * Math.floor((Mass - 100) / 50)))();
}
}
// This is the clearLabels function
// e:MouseEvent is the click event experienced by the textInput and the radioButtons
// void indicates that the function does not return a value
function clearLabels(e:MouseEvent):void
{
lblCost.text = "";
txtinMass.text = "";
}
我很确定错误是在我的最后2个if if语句中 . 当我把质量超过150克时,我试图让方程的答案出现 .
1 回答
问题出在
();
的结尾处 .因为你没有运行一个函数,所以最后尝试 not add “
()
” .尝试这样的事情: