【问题标题】:Google Maps Flash API disables bubbling of MouseEvent over their MarkersGoogle Maps Flash API 禁止 MouseEvent 在其标记上冒泡
【发布时间】:2009-05-12 14:14:36
【问题描述】:
默认情况下,Google Maps Flash API 会取消在其标记上发生的所有鼠标事件的冒泡(至少可拖动)。但是在 MapMouseEvent 构造函数中,我看到它有一个参数“气泡?”所以我猜他们可以用来冒泡鼠标事件?有没有办法打开鼠标事件的冒泡?
var __marker = new Marker(new LatLng(20, 20),
new MarkerOptions({
draggable: true,
tooltip:'Drag me'
}));
__map.addOverlay(__marker);
【问题讨论】:
标签:
flash
actionscript-3
google-maps
event-handling
mouseevent
【解决方案1】:
抱歉,我还没有在 Flash 中测试过新的 Google Maps API。据我记得,您可以将侦听器分配给标记,因此如果默认情况下禁用冒泡,理论上您需要做的就是为您拥有的所有标记侦听您想要的事件以及何时触发事件侦听器使用该处理程序中所需的所有数据调度您自己的自定义事件,并将冒泡设置为 true。
例如
//assuming SomeGoogleMarkerEvent is a Google Marker Event :)
//and CustomMarkerEvent is a subclass of Event (or another subclass of it )
function markerHandler(event:SomeGoogleMarkerEvent):void{
var customEvent:CustomMarkerEvent = new CustomMarkerEvent();
customEvent.marker = event.target;
dispatchEvent(customEvent,true);
}
我在dispatchEvent 调用中设置为true 的第二个参数正在冒泡。但请记住,只有 DisplayObjects 的事件会冒泡。有很多关于事件调度的resources,但我很容易忘记 DisplayObjects 和冒泡。
希望对你有帮助!