Flash 的dispatchEvent 被触发了两次
我有两个带有 as3 代码的框架:
// frame1:
gotoAndPlay("show controls");
// frame2 - have movieclip with name slide0
// create menu items click listeners
for (var i:int = 0; i < slides.items.length; i++) // slides.items.length = 1
this["menu_item"+i].addEventListener(MouseEvent.CLICK, menu_item_click);
// click on the first menu item
this["menu_item0"].dispatchEvent(new MouseEvent(MouseEvent.CLICK));
// menu item click handler
function menu_item_click(e:MouseEvent):void {
this["slide0"].gotoAndPlay("show");
}
// in movieclip slide0 on frame with label "show"
trace("slide0 show begin");
我收到 2 条消息“slide0 show begin”。但是当我点击 menu_item0 时,我收到一条消息。
请帮忙-哪里有错误?
I have two frames with as3 code:
// frame1:
gotoAndPlay("show controls");
// frame2 - have movieclip with name slide0
// create menu items click listeners
for (var i:int = 0; i < slides.items.length; i++) // slides.items.length = 1
this["menu_item"+i].addEventListener(MouseEvent.CLICK, menu_item_click);
// click on the first menu item
this["menu_item0"].dispatchEvent(new MouseEvent(MouseEvent.CLICK));
// menu item click handler
function menu_item_click(e:MouseEvent):void {
this["slide0"].gotoAndPlay("show");
}
// in movieclip slide0 on frame with label "show"
trace("slide0 show begin");
And I get 2 messages "slide0 show begin". But when I click on menu_item0 I have one message.
Please help - where is a mistake?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您也可以尝试一下 (
slides.items.length
) 您可以使用的数字。You can try it as well (
slides.items.length
) yeine numbers you can use.嗯,我将dispatchEvent 移至frame3,它工作正常。
但这种行为的原因尚不清楚......
Hmm, I move dispatchEvent to frame3 and it's working fine.
But the reason for such behavior is not clear...