8 Replies Latest reply on Oct 26, 2007 7:40 AM by kglad

# Finding the bounds of a movieclip

Version: Flash CS3, AS3

Is there a way to find the bounds (width&height) of a single-frame movieclip in a way that disregards surrounding whitespace?

ie. if a movieclip contains only a 10x10 square at point 5,5 (within the movieclip), width&height is normally returned as 15x15. I want a way to have 10x10 returned.

Flash seems to know of such bounds - the graphic displayed in the library sidebar is set to this size. So are they accessible via AS3?

Thanks
Rick
• ###### 1. Re: Finding the bounds of a movieclip
it's returned as 10 and 10, resp.
• ###### 2. Re: Finding the bounds of a movieclip
>> ie. if a movieclip contains only a 10x10 square at point 5,5 (within the
>> movieclip), width&height is normally returned as 15x15. I want a way to
>> have 10x10 returned.

Right... this is just how Flash works. You need to either position the
square at 0,0 within the clip, or make the square its own movieClip and get
the bounds of that clip specifically like: container.square._width.

--
Dave -
http://www.blurredistinction.com

• ###### 3. Re: Finding the bounds of a movieclip
Thanks Dave. So the answer to my question is 'no' - I need to either reposition the square, use another clip, or add two more variables.

Cheers,
Rick
• ###### 4. Re: Finding the bounds of a movieclip
width and height return the dimensions of the smallest rectangle that includes all on-stage objects. show me an example where you get 15x15 by placing a 10x10 square at 5,5.
• ###### 5. Re: Finding the bounds of a movieclip
Sorry kglad - you are right, I confused the question (it was nagging me a while back and I didn't recheck it).

The question should be:
How do I find the bounds of a movieclip relative to its position if its non-white space content is not placed with its top-left corner at the origin(0,0) within that clip?
ie. if a movieclip contains only a 10x10 square at point 5,5 (within the movieclip), width&height is normally returned as 10x10 but x,y is given as 0,0 (or wherever the clip is placed on stage). I want a way to either have 15x15 returned or 5,5

Thanks
Rick
• ###### 6. Re: Finding the bounds of a movieclip
oh...