In the following example, I'm trying to get the rectangle of "theParent" from 
the perspective of "theGrandparent" (theParent.getRect(theGrandparent)).  Here 
is the traced output:

0 0 100 250
0 0 100 100

I expected the rectangle of "theParent" to have a height of 100, which is its 
constrained height.  Instead, the rectangle has a height of 250, presumably 
including the height of "theChild".  

So getRect() looks like its returning _content_ height and not _display_ height.

Is this right?

My application problem is that I'm trying to select all objects intersecting a 
selection rectangle.  I was getting the rectangles of all children (using 
getRect) and calling intersects() on them.  It was then that I noticed that 
children that scrolled were returning rectangles larger than their display area 
on the screen.

What should I be doing instead?  Build the rectangle myself with 
theParent.width and theParent.height?

Example follows:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute" 
        applicationComplete="onApplicationComplete(event)">

    <mx:Script>
        <![CDATA[
        
                import mx.events.FlexEvent;
            
            private function onApplicationComplete(e:FlexEvent):void
            {
                var theParentRect:Rectangle;
                
                theParentRect = theParent.getRect(theGrandparent);
                
                trace(theParentRect.x, theParentRect.y, theParentRect.width, 
theParentRect.height);
                trace(theParent.x, theParent.y, theParent.width, 
theParent.height);
            }   
                
        ]]>
    </mx:Script>
        
        <mx:Canvas id="theGrandparent" width="200" height="200" 
backgroundColor="#00ff00">
                <mx:Canvas id="theParent" width="100" height="100" 
backgroundColor="#0000ff">
                        <mx:Canvas id="theChild" width="50" height="250" 
backgroundColor="#ff0000"/>
                </mx:Canvas>
        </mx:Canvas>
        
</mx:Application>



Reply via email to