I'm afraid that doesn't do it either - the problem is, a Canvas with a backgroundImage style set will never be the target of a click event, the backgroundImage will always get in the way. I think I'm going to have to refactor the whole thing at this point...
On Tue, Mar 17, 2009 at 3:51 PM, Tim Hoff <[email protected]> wrote: > 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. > > > > > > > > > > > > > > > > > >

