Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Posts: 1,008
Registered: ‎12-12-2010
My Device: Passport (Red Limited Edition)
My Carrier: Mobile Vikings
Accepted Solution

Label on top of Sprite Event handling

Hi everybody, this is more of a general Actionscript question, but Google doesn't offer any answers.

 

So I have made a custom component, Element, which extends the Sprite class. I draw some things on the graphics of this class and then I add a Label to display text.

 

In another class, where I create instances of the former class, I add an EventListener for MouseEvent.Click.  In that function there is this line:

 

 

selectedElement = Element(event.target);

 

 

In short, I want the selectedElement variable to hold the Element that was clicked. But I ran into problems, event.target is not always an instance of my class. If I click where the Label is, event.target is a Label.

 

How can I arrange that if click anywhere on my Element, especially on the Label, that it is the Element class that dispatches an event and not the Label. I think I must intercept the Labels events somehow, but no clue how I do this.

 

Thank you in advance.

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Highlighted
Developer
Posts: 1,008
Registered: ‎12-12-2010
My Device: Passport (Red Limited Edition)
My Carrier: Mobile Vikings

Re: Label on top of Sprite Event handling

Never mind, the stopPropagation method in the Event class was what I was looking for.

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!