我有一个简单的flash场景,其中包含的影片剪辑包含每隔几秒钟更改一次的滑动按钮:
每个图层都包含一个按钮和另一个影片剪辑。
如果我想将事件监听器添加到舞台上的一个简单按钮,我只需写:
f4.addEventListener(MouseEvent.CLICK, f4Click);
function f4Click(event:MouseEvent):void
{
flash.external.ExternalInterface.call("dlHTCMD", "switchtogame?code=fnf50");
}
但是当我试图访问两个影片剪辑中的按钮时,比如
optContainer.optBeach.btnBeach.addEventListener(MouseEvent.CLICK, btnBeachClick);
我正在添加一个trace
函数来查看事件是否被触发但没有发生任何事情。
看起来像一个简单的问题,但我找不到解决方案。
我考虑过扩展按钮类并添加一个带有值作为按钮名称的绑定函数并设置事件监听器,但我不是AS3专家:(
感谢。
答案 0 :(得分:0)
试试这个:
// Pass mouse events to children
optContainer.mouseChildren = true;
optContainer.optBeach.mouseChildren = true;
// Reset hit area
optContainer.hitArea = null;
optContainer.optBeach.hitArea = null;
// Reset masks
optContainer.mask= null;
optContainer.optBeach.mask= null;
同时检查每个关键帧按钮上是否有名称。