Search code examples
flashactionscript-3actionscriptflashbuilder4

How to check if a number is between two other numbers in Actionscript 3?


How can i check if a number is between two other numbers like:

pseudocode:

var = 458;

if (var is between 0 and 1000) give positive.

if (var is between 1001 and 2000) give negative.

if (var is between 2001 and 3000) give negative.

in AS3?

Thanks in advance.


Solution

  • If You will check it many times, simply create function :

    function check(min:Number , value:Number , max:Number):Boolean{
        return min > value ? false : ( max < value ? false : true );
    }
    

    It will return true if value is between min and max.