I'd probably do it using getBounds and the Rectangle class's comparison
methods.

 

var canvasBounds :Rectangle = myCanvas.getBounds(myCanvas.parent);

var componentBounds:Rectangle = myComponent.getBounds(myCanvas.parent);

 

and then either

 

if(canvasBounds.contains(componentBounds))

 

or

 

if(canvasBounds.intersects(componentBounds))

 

 

Michael Krotscheck

Senior Developer

 
RESOURCE INTERACTIVE

<http://www.resource.com/> www.resource.com <http://www.resource.com> 

[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 

________________________________________________________________________
____
This email and any of its attachments may contain Resource Interactive
proprietary information, which is privileged, confidential and may be
subject to copyright or other intellectual property rights belonging to
Resource Interactive. This email is intended solely for the use of the
individual or entity to which it is addressed. If you are not the
intended recipient of this email, you are hereby notified that any
dissemination, distribution, copying or action taken in relation to the
contents of and attachments to this email is strictly prohibited and may
be unlawful. If you have received this email in error, please notify the
sender immediately and permanently delete the original and any copy of
this email and any printout.


________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Brian
Sent: Friday, November 02, 2007 10:16 AM
To: [email protected]
Subject: [flexcoders] how to determine if a component is offscreen in a
Canvas?

 

I'm using a Canvas where I'm adding components dynamically at absolute
positions, which may increase the size of the canvas beyond it's
parent container. When this happens, scrollbars are created, as
expected and desired. I'm trying to figure out if the component I just
added are offscreen, in the clipped area. If that's the case, I want
to be able to make that newly-added component visible by manually
adjusting the scrollbars.

I've done this before in another development environment so I know the
logic to do, but I'm new to Flex and struggling to find which
properties to use, amongst all the different properties and methods,
i.e. height, maxHeight, measuredHeight, scrollPosition, etc.

Thanks

 

Reply via email to