2017-07-16 116 views
0

我是ActionSccript 3.0的初学者。我做了这个代码工作正常,但是当我把数量超过150克,我得到错误输出说错误#1006:值不是一个函数请帮助。介意告诉我正确的代码?谢谢Actionscript 3.0:错误#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 else语句。当我把质量超过150克时,我试图让方程的答案出现。

+0

在过去的两个街区你计算一些** **号,然后突然把它作为一个功能**()**。就像** 0.74(); **当然,Flash Player拒绝执行这样的请求。 – Organis

回答

1

问题出在();的末尾。
尝试最后不要加()”,因为你没有运行函数。

尝试是这样的:

lblCost = ((0.55 + 0.19 * Math.floor((Mass - 100)/50))); 
+0

现在我得到2个语法错误。错误1076:将值类型数字隐式强制转换为不相关的类型字符串。这在lblCost.text =((0.55 + 0.19 * Math.floor((Mass-100)/ 50)));和lblCost.text =((0.73 + 0.24 *((Mass-100)/ 50)); – guest343435

+0

UPDATE:我发现我的错误是什么,现在我的程序运行正常。 – guest343435

相关问题