根据 Jeff Posnick 的回答(没有官方的方式来做到这一点),我最终使用相当于屏幕抓取的代码拼凑了一个脆弱的解决方案。
在鼠标单击时,我会遍历无镶边播放器的 DisplayObject 层次结构,过滤掉噪音,并查看当前点下是否存在与鼠标交互的对象。
它很脆弱——未来对无铬播放器的更改很容易打破这一点。如果重叠式广告包含 AVM1 内容,它将无法访问并且会吃掉鼠标事件。但总比没有好。:(
这是一些示例代码来演示该概念。传入无铬播放器的 DisplayObject,以及舞台空间中的当前鼠标位置。这将返回该点下是否有鼠标交互元素,并将跟踪支持的鼠标交互是什么。
private function IsPointInteractive(displayObject:DisplayObject,
stageX:Number,
stageY:Number) : Boolean
{
const className:String = flash.utils.getQualifiedClassName(displayObject);
const container:DisplayObjectContainer = displayObject as DisplayObjectContainer;
if (!displayObject.visible)
return false;
if (className != "com.google.youtube.application::SwfProxy" &&
className != "com.google.youtube.application::VideoApplication" &&
className != "com.google.youtube.players::HTTPVideoPlayer" &&
className != "com.google.youtube.players::TagStreamPlayer" &&
(null == container || container.mouseEnabled) &&
displayObject.hitTestPoint(stageX, stageY, true) )
{
var supports:String = "";
if (displayObject.hasEventListener(MouseEvent.CLICK))
supports += "MouseEvent.CLICK";
if (displayObject.hasEventListener(MouseEvent.DOUBLE_CLICK))
supports += (0 == supports.length ? "" : ", ") + "DOUBLE_CLICK";
if (displayObject.hasEventListener(MouseEvent.MOUSE_DOWN))
supports += (0 == supports.length ? "" : ", ") + "MOUSE_DOWN";
if (displayObject.hasEventListener(MouseEvent.MOUSE_UP))
supports += (0 == supports.length ? "" : ", ") + "MOUSE_UP";
if (0 != supports.length)
{
trace(displayObject + " (" + className + ") [" + supports + "]");
return true;
}
}
if (container && container.mouseChildren)
{
for (var i:int = container.numChildren - 1; i >= 0; i--)
{
if (IsPointInteractive(container.getChildAt(i), stageX, stageY))
return true;
}
}
return false;
}