EqualsObject

The asdk.condition.EqualsObject is used to test two objects for equality. This implementation of the UnaryCondition interface that when executed will determine whether objects passed to the execute method are equal to the object that is passed in to the constructor. This allows for encapsulation of the logic for determining equality of a particular object with other objects.

Below is a simple demonstration of how to use this class:

1
2
3
4
5
6
7
8
9
10
11
var orange = "orange";
var grapes = "grapes";
var anOrange:asdk.condition.UnaryCondition = new asdk.condition.EqualsObject( "orange" );

var isAnOrange = anOrange.execute( orange );
trace( "isAnOrange: " + isAnOrange );
//displays isAnOrange: true in output window

var areGrapesAnOrange = anOrange.execute( grapes );
trace( "areGrapesAnOrange: " + areGrapesAnOrange );
//displays areGrapesAnOrange: false in output window

Note that the string "orange" is passed in to the constructor on line 3 when the EqualObject is created. All subsequent calls to the execute method will compare the the object passed in to the execute method with this "orange" string. Therefore line 5 will return true when the orange variable is passed to the execute method, but line 9 will return false when the grapes variable is executed.