If you do some testing, you'll probably find that it's not actually adding the event for the children, it's just that the mouseover event for the parent is behaving like the children have it too.
Yes, but I don't want to behave like that. I'm thinking of adding an EventListener into the parent (it won't add the behavior to the children) and when it triggers it will throw an Event and Flex will catch it. But I don't like this solution, too complicated and I have poor control here.
Do you have any suggestion ?
What are you trying to achieve? Do you want to get mouseover only when the mouse is over a part of the parent that is not occupied by a child? In any case, this is a Flash issue, not AIR.
My code is something like this:
public class CustomObject extends UIMovieClip
private var avatar:UIMovieClip;
public function CustomObject(image:UIMovieClip)
avatar = image;
var object:CustomObject = new CustomObject( new AvatarObject);
I want to play the animation when the mouse is over my object and stop when the mouse leaves it. But when the users moves over the parent but from a child to another the MOUSE_OUT event is triggered. I don't want that to happen, the children shouldn't have this behavior, only the parent object. I don't even understand why they have this behavior.
It's possible that your object has 'holes' in it, i.e. that it contains children but nothing between them. In this case, mouse movements between the children will generate mouse in/out events. If this is the case, simply add a transparent shape in the background of the object.
If this is not the case - do you need any kind of mouse interaction for the children? If not, you can just add
object.mouseChildren = false;
If both tips don't work - this is not likely but just in case - why not check the value of the mouse event's currentTarget property? If it's not the AvatarObject but rather one of its children, ignore the event.
Yurika ! Thanks imdfl (^^,)
My object has an irregular shape and is an animation so I can't add a transparent shape, but object.mouseChildren = false did the job.