AS3 - 获取上下文菜单选择
如何查明选择了哪个菜单项?
cm1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,changeColor);
cm2.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,changeColor);
function changeColor(event:ContextMenuEvent):void{
trace("cm1 or cm2?")
}
谢谢。
How to find out which menu item was selected?
cm1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,changeColor);
cm2.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,changeColor);
function changeColor(event:ContextMenuEvent):void{
trace("cm1 or cm2?")
}
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
跟踪事件目标以找出当前目标(被单击的)
Trace the event target to find out the current target (that was clicked)
如果可能,请向每个上下文菜单元素添加单独的侦听器:
cm1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, changeColorCM1);
cm2.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,changeColorCM2);
函数changeColorCM1(事件:ContextMenuEvent):void{ //CM1 }
函数changeColorCM2(事件:ContextMenuEvent):void{ //CM2 }
If possible, add separate listeners to each context menu element:
cm1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, changeColorCM1);
cm2.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,changeColorCM2);
function changeColorCM1(event:ContextMenuEvent):void{ //CM1 }
function changeColorCM2(event:ContextMenuEvent):void{ //CM2 }