Ok, maybe just check it's type:

if (evt.target is FlexLoader)

-TH

--- In [email protected], Ken Dunnington <ken.dunning...@...>
wrote:
>
> Hi Tim, unfortunately, that's exactly what happens :)
> If you apply a backgroundImage, the target of the click event will be
the
> FlexLoader instance for that image, or in the case of a SWF, it'll be
the
> actual SWF instance. To make matters worse, the background image is
(as far
> as I've been able to tell) indistinguishable from a regular child, in
that
> it counts towards numChildren's value, returns true on contains() and
owns()
> etc. I'm looking through the SDK source to try to find exactly where
it's
> added and how it manages to stay behind everything, but this is
certainly
> puzzling.
> - Ken
>
> On Tue, Mar 17, 2009 at 2:36 PM, Tim Hoff timh...@... wrote:
>
> > Hi Ken,
> >
> > I'm pretty sure that the target will never be the background image
itself;
> > but rather the Canvas. One hack is to check the type:
> >
> > if (evt.target is Canvas)
> >
> > -TH
> >
> >
> > --- In [email protected], Ken Dunnington ken.dunnington@
> > wrote:
> > >
> > > I've got a custom component based on Canvas, and I'm
programmatically
> > > setting its background-image style to a loaded SWF. I need to be
able to
> > > differentiate between a click on the background, and a click on
any of
> > the
> > > other children. WIth no background set, I was using this code:
> > >
> > > private function clickHandler (evt:MouseEvent):void
> > >
> > > {
> > >
> > > if (evt.target == this)
> > >
> > > {
> > >
> > > setFocus();
> > >
> > > dispatchEvent(new CanvasEvent(CanvasEvent.CLEAR_FOCUS));
> > >
> > > }
> > >
> > > }
> > >
> > >
> > > WIth a background-image, however, this no longer works. I've also
tried
> > > listening for the target phase, but the event never actually
reaches the
> > > canvas object. I do have a separate ICollectionView instance
containing
> > all
> > > the other children, but I'd like to avoid having to use that for
this
> > > handler, if possible.
> > >
> >
> >
> >
>


Reply via email to