Rectangle

Properties

Can be described in 3 ways...

1. left, top, right, bottom

2. x, y, width, height

3. size, topLeft, bottomRight

left

var left: Number

top

var top: Number

right

var right: Number

bottom

var bottom: Number

x

var x: Number

y

var y: Number

width

var width: Number

height

var height: Number

size

var size: Point

bottomRight

var bottomRight: Point

topLeft

var topLeft: Point

Methods

Rectangle

function Rectangle(x : Number,
y : Number,
w : Number,
h : Number)

Constructor.  Instantiates a new Rectangle Object.

Example

//local function: drawRect
var drawRect = function(r:flash.geom.Rectangle size:Number, tgt:MovieClip, color: Number){
if (!color) color = 0x000000; //black
tgt.lineStyle(size, color);
tgt.moveTo(r.left, r.top);
tgt.lineTo(r.right, r.top);
tgt.lineTo(r.right, r.bottom);
tgt.lineTo(r.left, r.bottom);
tgt.lineTo(r.left, r.bottom);
tgt.lineTo(r.left, r.top);
}

//Draw a diagonal line of Rects 20 pixels apart
for(var i = 10; i < 200; i += 20){
var rectClip = myClip.createEmptyMovieClip("rectClip" + i, myClip.getNextHighestDepth());
var myRect = new flash.geom.Rectangle(i, i, 40, 40);
rectClip.opaqueBackground = Math.round(Math.random() * 0xFFFFFF); //assign random color to inside of rect
drawRect(myRect, 2, rectClip);
}

equals

function equals(r : Rectangle) : Boolean

union

function union(r : Rectangle) : Rectangle

intersects

function intersects(r : Rectangle) : Boolean

intersection

function intersection(r : Rectangle) : Rectangle

containsRectangle

function containsRectangle(r : Rectangle) : Boolean

containsPoint

function containsPoint(p : Point) : Boolean

contains

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

offsetPoint

function offsetPoint(p : Point) : Void

offset

function offset(x : Number,
y : Number) : Void

inflatePoint

function inflatePoint(p : Point) : Void

inflate

function inflate(x : Number,
y : Number) : Void

isEmpty

function isEmpty() : Boolean

setEmpty

function setEmpty() : Void

clone

function clone() : Rectangle

toString

function toString() : String
var left: Number
var top: Number
var right: Number
var bottom: Number
var x: Number
var y: Number
var width: Number
var height: Number
var size: Point
var bottomRight: Point
var topLeft: Point
function Rectangle(x : Number,
y : Number,
w : Number,
h : Number)
Constructor.
function equals(r : Rectangle) : Boolean
function union(r : Rectangle) : Rectangle
function intersects(r : Rectangle) : Boolean
function intersection(r : Rectangle) : Rectangle
function containsRectangle(r : Rectangle) : Boolean
function containsPoint(p : Point) : Boolean
function contains(x : Number,
y : Number) : Boolean
function offsetPoint(p : Point) : Void
function offset(x : Number,
y : Number) : Void
function inflatePoint(p : Point) : Void
function inflate(x : Number,
y : Number) : Void
function isEmpty() : Boolean
function setEmpty() : Void
function clone() : Rectangle
function toString() : String