Okay, found this in the archives:

http://tech.groups.yahoo.com/group/flexcoders/message/48653

So, I tried out the function at the end of the thread. Seems the one
thing I was doing wrong (?) was this:

I called this.getObjectsUnderPoint(point); where this was a Sprite at
the root of my UIComponent.

Everything works correctly if I instead call
this.stage.getObjectsUnderPoint(point).

That... well, doesn't make sense. Anyone care to clarify?

Troy.




--- In flexcoders@yahoogroups.com, "thirtyfivemph" <[EMAIL PROTECTED]>
wrote:
>
> Okay, this is really driving me crazy...
> 
> I've got a UIComponent which is nested several layers deep in a
> layout. Inside that UIComponent I've got a series of sprites that are
> nested one inside of the other 4 or 5 levels deep with a Bitmap nested
> as the deepest level.
> 
> In the top-level sprite of my UIComponent (child of the UIComponent)
> I'm intercepting mouse clicks (sprite.mouseChildren = false) and
> trying to determine what underlying sprite was clicked on (think the
> SpriteArranger example).
> 
> Easy, right? Just take the stageX and stageY coordinates from the
> mouse down event, pass them to getObjectsUnderPoint, and voila, a list
> of objects (sprites, bitmaps, etc.) underneath that point on the stage.
> 
> But its not working for me... a few weird issues are popping up:
> 
> First, 99% the only object that is in the returned list is the
> top-level sprite of my component. What's weird is its the
> DisplayObjectContainer I'm calling getObjectsUnderPoint on, so I
> wouldn't expect it to be included in the list (because the docs say
> "children, grandchildren, etc.").
> 
> Second, the 1% of the time it finds something else its the deepest
> child, the Bitmap, which is the only other object with art, so that's
> too be expected. But it only finds the object if I click on the top
> edge of the bitmap. E.g., if I click at (20, 120) it finds the bitmap,
> but if I click at (20, 121) or (20, 119) it doesn't find the bitmap,
> even though its 100x100 (its fairly big on the screen, I can tell when
> I'm clicking inside of it!).
> 
> And I check the hitArea... NULL on all my DisplayObjects, so they
> should be running off of the visual areas...
> 
> Third, the getPointsUnderObject seems to be offset... the docs say to
> use stage coordinates, so I use the stageX and stageY from the mouse
> event. But, no objects are returned when I reach the edge of my
> UIComponent due to what appears to be some offset due to the fact that
> the UIComponent is centered...
> 
> ARrrgh!
> 
> This seems so basic? Are there gotchas I'm not aware of when dealing
> with getObjectsUnderPoint? I can find very few examples of this being
> used and the ones I can find seem to agree with what I'm doing!
> 
> Help! Please help! :)
> 
> Troy.
>


Reply via email to