ActionScript 3.0: ошибка № 1006: значение не является функцией

Я новичок в ActionScript 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 = ""; 
}

Я почти уверен, что ошибка в моих последних двух операторах else if. Я пытаюсь сделать так, чтобы ответы уравнений появлялись, когда я помещаю массу более 150 граммов.


person guest343435    schedule 16.07.2017    source источник
comment
В последних двух блоках вы вычисляете некоторое Число, а затем неожиданно вызываете его как функцию с помощью (). Например, 0.74(); Разумеется, Flash Player отказывается выполнять такой запрос.   -  person Organis    schedule 16.07.2017


Ответы (1)


Проблема заключается в строках с (); в конце.
Попробуйте не добавлять "()" в конце, так как вы не запускаете функцию.

Попробуйте что-то вроде этого:

lblCost = (( 0.55 + 0.19 * Math.floor((Mass - 100) / 50) ));
person user8314196    schedule 16.07.2017
comment
Теперь я получаю 2 синтаксические ошибки. Ошибка 1076: Неявное приведение типа значения Number к несвязанному типу String. Это видно на lblCost.text = (( 0,55 + 0,19 * Math.floor((Mass - 100) / 50) )); и lblCost.text = ((0,73 + 0,24 * ((Масса - 100) / 50)); - person guest343435; 17.07.2017
comment
ОБНОВЛЕНИЕ: я узнал, в чем заключались мои ошибки, и теперь моя программа работает правильно. Спасибо за вашу помощь. - person guest343435; 17.07.2017