我是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克时,我试图让方程的答案出现。
答案 0 :(得分:1)
问题在于结尾处();
的行
尝试不添加&#34; ()
&#34;最后,因为你没有运行一个函数。
尝试这样的事情:
lblCost = (( 0.55 + 0.19 * Math.floor((Mass - 100) / 50) ));