NegativeNumber

The asdk.condition.NegativeNumber class is used to test for a negative number condition. It provides an implementation of the UnaryCondition interface that when executed will determine whether the operand passed to the execute method is negative. This allows for encapsulation of the logic for determining whether or not a number is negative. The example below demonstrates the use of this class:

1
2
3
4
5
6
7
8
9
10
11
12
13
var isNegativeCondition : UnaryCondition = new NegativeNumber();

var isNegativeOneNegative = isNegativeCondition.execute( -1 );
trace("isNegativeOneNegative: " + isNegativeOneNegative );
//displays isNegativeOneNegative: false in output window

var isZeroNegative = isNegativeCondition.execute( 0 );
trace("isZeroNegative: " + isZeroNegative );
//displays isZeroNegative: false in output window

var isOneNegative = isNegativeCondition.execute( 1 );
trace("isOneNegative: " + isOneNegative );
//displays isOneNegative: true in output window

In this example only the last call to the execute method returns true when the number -1 is tested as a negative number.