equals (Rectangle.equals method)

public equals(toCompare:Object) : Boolean

Determines whether the object specified in the toCompare parameter is equal to this Rectangle object. This method compares the x, y, width, and height properties of an object against the same properties of this Rectangle object.

Availability: ActionScript 1.0; Flash Player 8

Parameters

toCompare:Object - The rectangle to compare to this Rectangle object.

Returns

Boolean - If the object has exactly the same values for the x, y, width, and height properties as this Rectangle object, returns true; otherwise false.

Example

In the following example, rect_1 and rect_2 are equal, but rect_3 is not equal to the other two objects because its x, y, width, and height properties are not equal to those of rect_1 and rect_2.

import flash.geom.Rectangle;

var rect_1:Rectangle = new Rectangle(0, 0, 50, 100);
var rect_2:Rectangle = new Rectangle(0, 0, 50, 100);
var rect_3:Rectangle = new Rectangle(10, 10, 60, 110);

trace(rect_1.equals(rect_2)); // true;
trace(rect_1.equals(rect_3)); // false;

Even though the method signature expects only an abstract object, only other Rectangle instances are treated as equal.

import flash.geom.Rectangle;

var rect_1:Rectangle = new Rectangle(0, 0, 50, 100);
var nonRect:Object = new Object();
nonRect.x = 0;
nonRect.y = 0;
nonRect.width = 50;
nonRect.height = 100;
trace(rect_1.equals(nonRect));

See also

x (Rectangle.x property), y (Rectangle.y property), width (Rectangle.width property), height (Rectangle.height property)


Flash CS3