Reputation: 19204
Run the following code, once with block.mouseEnabled = true, and again with block.mouseEnabled = false, clicking the block once during each run.
var block:Sprite = new Sprite();
block.name = "block";
with(block.graphics){beginFill(0x000000,1);moveTo(0,0);lineTo(100,0);lineTo(100,100);lineTo(0,100);lineTo(0,0);endFill();}
block.mouseEnabled = true; //change to false to see how event target skips root
addChild(block)
stage.addEventListener( MouseEvent.MOUSE_DOWN, mouse_down, false, 0, true );
function mouse_down( e:MouseEvent ):void{trace( e.target );}
Why is "root" skipped as a target? Is this by design? What is or what might be the design reason for this anomaly?
I ask this because it's a clear a break from the normal pattern where when the child object has mouseEnabled set to false, the parent becomes the target when it's child area is clicked.
It may be that the root is simply a non-participant endpoint in the event capture/target/bubbling rount-trip, and anything that reaches it gets applied to stage instead of root.
Upvotes: 2
Views: 404
Reputation: 497
Any strokes and vector-fills on graphics are not interactive and cant catch interactive events. U can use graphics.beginBitmapFill method or add Bitmap (or any other) as child into.
Upvotes: 1