Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > Rectangle (flash.geom.Rectangle) > union (Rectangle.union method) | |||
public union(toUnion:Rectangle) : Rectangle
Adds two rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two rectangles.
Availability: ActionScript 1.0; Flash Player 8
toUnion:Rectangle - A Rectangle object to add to this Rectangle object.
Rectangle - A new Rectangle object that is the union of the two rectangles.
The following example creates a Rectangle object out of the union of two others.
For example, consider a rectangle with properties x=20, y=50, width=60, and height=30 (20, 50, 60, 30), and a second rectangle with properties (150, 130, 50, 30). The union of these two rectangles is a larger rectangle that encompasses the two rectangles with the properties (20, 50, 180, 110).
import flash.geom.Rectangle; var rect_1:Rectangle = new Rectangle(20, 50, 60, 30); var rect_2:Rectangle = new Rectangle(150, 130, 50, 30); var combined:Rectangle = rect_1.union(rect_2); trace(combined.toString()); // (x=20, y=50, w=180, h=110)
Flash CS3