intersection (Rectangle.intersection method)

public intersection(toIntersect:Rectangle) : Rectangle

If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, the intersection() method returns the area of intersection as a Rectangle object. If the rectangles do not intersect, this method returns an empty Rectangle object with its properties set to 0.



Availability: ActionScript 1.0; Flash Player 8

Parameters

toIntersect:Rectangle - The Rectangle object to compare against to see if it intersects with this Rectangle object.

Returns

Rectangle - A Rectangle object that equals the area of intersection. If the rectangles do not intersect, this method returns an empty Rectangle object; that is, a rectangle with its x, y, width, and height properties set to 0.

Example

The following example determines the area where rect_1 intersects rect_2.

import flash.geom.Rectangle;

var rect_1:Rectangle = new Rectangle(0, 0, 50, 50);
var rect_2:Rectangle = new Rectangle(25, 25, 100, 100);
var intersectingArea:Rectangle = rect_1.intersection(rect_2);
trace(intersectingArea.toString()); // (x=25, y=25, w=25, h=25)

Flash CS3