01-06-2011 12:18 PM
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.
Solved! Go to Solution.
01-06-2011 12:43 PM
Never mind, the stopPropagation method in the Event class was what I was looking for.