Home > actionscript, bugs > mouse events aren’t dispatched for graphics drawn on main display class

mouse events aren’t dispatched for graphics drawn on main display class

This is bizarre. It appears the main display object’s graphics object is rendered on Stage and not its own display as in the example above:

In the Actionscript Project published above I have a red square drawn on the graphics of the main Sprite class and a child sprite with a green square and a textfield to the right to trace clicks.
I have MouseEvent.CLICK listeners on stage, main sprite ClickTest, and child Sprite. With mouse children disabled clicking anywhere will report a single MouseEvent.CLICK to stage even though they should be dispatching for both the main display and stage. With mouseChildren enabled the top square will still only trigger the Stage mouse listener but the bottom will correctly trigger the click on the child sprite, main parent ClickTest sprite, and stage showing that the main DisplayObject is participating in the mouse event bubbling.

Thus my conclusion that the main display object’s graphics object is rendered on Stage which can cause a lot of unexpected behavior and confusion.  Your root display class cannot listen to its own display to catch mouse events for its own graphics object. I guess this could make enough sense if the root display object shared its display with the root Stage but as this hierarchy diagram shows, it shouldn’t: http://www.adobe.com/devnet/flash/quickstart/display_list_programming_as3/

I’d consider it one of those bizarre architecture inconsistencies like swfs having references to stage in the constructor when ran stand alone but not when they are loaded into another swf, its just inconsistent and asking for trouble?

Categories: actionscript, bugs Tags:
  1. No comments yet.
  1. No trackbacks yet.