这个简单的代码在红色画布上显示了一个绿色画布,我希望绿色画布让鼠标按下事件被他身后的孩子抓住:红色画布。
我怎样才能做到这一点 ?
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()">
<mx:Canvas id="bg" width="100%" height="100%" backgroundColor="white" />
<mx:Script>
<![CDATA[
private function init():void {
var cvstest:Canvas = new Canvas();
cvstest.width = 200;
cvstest.height = 200;
cvstest.x = 100;
cvstest.doubleClickEnabled = true;
cvstest.addEventListener(MouseEvent.DOUBLE_CLICK, dc);
cvstest.addEventListener(MouseEvent.MOUSE_DOWN, md);
cvstest.setStyle("backgroundColor",0xff0000);
this.addChild(cvstest);
var cvsselect:Canvas = new Canvas();
cvsselect.width = 20;
cvsselect.height = 20;
cvsselect.x = 140;
cvsselect.doubleClickEnabled = false;
cvsselect.mouseChildren = true;
cvsselect.addEventListener(MouseEvent.MOUSE_DOWN, md2);
cvsselect.setStyle("backgroundColor",0x00ff00);
this.addChild(cvsselect);
}
public function dc (e:MouseEvent) : void {
trace("DOUBLE CLICK ON TEST CANVAS");
}
public function md (e:MouseEvent) : void {
trace("SINCLICK ON TEST CANVAS");
}
public function md2 (e:MouseEvent) : void {
trace("GREEN CLICK ON TEST CANVAS");
}
]]>
</mx:Script>
</mx:Application>