guest343435
guest343435

Reputation: 1

Actionscript 3.0: Error #1006: value is not a function

I am a beginner at ActionSccript 3.0. I made this code which works fine but when I put an amount over 150 grams, i get an error in the output that says Error #1006: value is not a function Please Help. Mind telling giving me the correct code? Thank you

//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 = ""; 
}

I'm pretty sure the error is in my last 2 else if statement. I'm trying to make the answer of the equations appear when i put a mass over 150 grams.

Upvotes: 0

Views: 454

Answers (1)

user8314196
user8314196

Reputation: 11

The problem is in the lines with (); at the ending.
Try to not add the "()" at the end, since you are not running a function.

Try something like this :

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

Upvotes: 1

Related Questions