Scale Error | Precision Problems width, height, getBounds | ActionScript 3.0 (AS3)

Precision Pitfalls Between getRect and Width/Height

Keep in mind when you are using

var boundingBox:Rectangle = mc.getRect(coordSystem)

or

var boundingBox:Rectangle = mc.getBounds(coordSystem)

the Rectangle returned will be of a greater precision than mc.x, mc.y, mc.width and mc.height

trace (mc.width == boundingBox.width)

will often return false.

Also keep in mind that getRect and getBounds also can return different results depending on the contents of the DisplayObject.

getBounds returns a rectangle that defines the area of the display object including lines and shapes

getRect returns the rectangle including the extra gurth added by outline strokes on shapes.

Comments (0)add comment

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
smile
wink
laugh
grin
angry
sad
shocked
cool
tongue
kiss
cry
smaller | bigger

security image
Write the displayed characters


busy