Rectangle (flash.geom.Rectangle)


Object
    |
    +-flash.geom.Rectangle

public class Rectangle
extends Object

The Rectangle class is used to create and modify Rectangle objects. A Rectangle object is an area defined by its position, as indicated by its top-left corner point (x, y), and by its width and its height. Be careful when you design these areas--if a rectangle is described as having its upper-left corner at 0,0 and has a height of 10 and a width of 20, the lower-right corner is at 9,19, because the count of width and height began at 0,0.

The x, y, width, and height properties of the Rectangle class are independent of each other; changing the value of one property has no effect on the others. However, the right and bottom properties are integrally related to those four--if you change right, you are changing width; if you change bottom, you are changing height, and so on. And you must have the left or x property established before you set width or right property.

Rectangle objects are used to support the BitmapData class filters. They are also used in the MovieClip.scrollRect property to support the ability to crop and scroll a MovieClip instance with specific width, height and scrolling offsets.

Availability: ActionScript 1.0; Flash Player 8

See also

scrollRect (MovieClip.scrollRect property)

Property summary

Modifiers

Property

Description

 

bottom:Number

The sum of the y and height properties.

 

bottomRight:Point

The location of the Rectangle object's bottom-right corner, determined by the values of the x and y properties.

 

height:Number

The height of the rectangle in pixels.

 

left:Number

The x coordinate of the top-left corner of the rectangle.

 

right:Number

The sum of the x and width properties.

 

size:Point

The size of the Rectangle object, expressed as a Point object with the values of the width and height properties.

 

top:Number

The y coordinate of the top-left corner of the rectangle.

 

topLeft:Point

The location of the Rectangle object's top-left corner determined by the x and y values of the point.

 

width:Number

The width of the rectangle in pixels.

 

x:Number

The x coordinate of the top-left corner of the rectangle.

 

y:Number

The y coordinate of the top-left corner of the rectangle.

Properties inherited from class Object

constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property)


Constructor summary

Signature

Description

Rectangle(x:Number, y:Number, width:Number, height:Number)

Creates a new Rectangle object whose top-left corner is specified by the x and y parameters.

Method summary

Modifiers

Signature

Description

 

clone() : Rectangle

Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.

 

contains(x:Number, y:Number) : Boolean

Determines whether the specified point is contained within the rectangular region defined by this Rectangle object.

 

containsPoint(pt:Point) : Boolean

Determines whether the specified point is contained within the rectangular region defined by this Rectangle object.

 

containsRectangle(rect:Rectangle) : Boolean

Determines whether the Rectangle object specified by the rect parameter is contained within this Rectangle object.

 

equals(toCompare:Object) : Boolean

Determines whether the object specified in the toCompare parameter is equal to this Rectangle object.

 

inflate(dx:Number, dy:Number) : Void

Increases the size of the Rectangle object by the specified amounts.

 

inflatePoint(pt:Point) : Void

Increases the size of the Rectangle object.

 

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.

 

intersects(toIntersect:Rectangle) : Boolean

Determines whether the object specified in the toIntersect parameter intersects with this Rectangle object.

 

isEmpty() : Boolean

Determines whether or not this Rectangle object is empty.

 

offset(dx:Number, dy:Number) : Void

Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts.

 

offsetPoint(pt:Point) : Void

Adjusts the location of the Rectangle object using a Point object as a parameter.

 

setEmpty() : Void

Sets all of the Rectangle object's properties to 0.

 

toString() : String

Builds and returns a string that lists the horizontal and vertical positions and the width and height of the Rectangle object.

 

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.

Methods inherited from class Object

addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString method), unwatch (Object.unwatch method), valueOf (Object.valueOf method), watch (Object.watch method)



Flash CS3