Onret
Onret

Reputation: 47

1170: Function does not return a value

I am a bit new to flash and actionscript but i am learning. With this code I am trying to get a message that says true when the value is between from and to. When I run this it gives the error in the title. What am I doing wrong?

from = Number(txtFra.text);
value = Number(txtTall.text);
to = Number(txtTil.text);
var from:Number;
var value:Number;
var value:Number;

function insideIntervall(from:int, value:int, to:int):Boolean
{
    var bool:Boolean
    if (from<value<to)
    {
        bool = true;
    }
    else
    {
        bool = false;
    }
    if (bool == true)
    {
        trace("True");
    }
    else
    {
        trace("False");
    }
}

Upvotes: 0

Views: 497

Answers (1)

Eduardo
Eduardo

Reputation: 8392

The error in the title is because your function must explicitly return a value. You do this with the keyword return.

However, there is another error in your program: you cannot compare from<value<to. What you need to check is that from < value && value < to. Basically, that both conditions are true.

The body of your function could then be simplified to: return from < value && value < to;

Upvotes: 3

Related Questions