正在做一个项目,当我点击一个按钮时,我一直在使用gotoAndPlay转到certian框架。当我点击按钮它会把我带到框架但如果我再次点击它会进入下一帧它为我的所有按钮(4)
activities.addEventListener(MouseEvent.CLICK, gotoActivities);
function gotoActivities (event):void{
gotoAndPlay(255);
}
当我进入页面时是否需要禁用事件监听器并在我离开时再次启用它或者是否有其他方式可以执行此操作?
由于
答案 0 :(得分:0)
您可以从处理程序本身中删除它。
activities.addEventListener(MouseEvent.CLICK, gotoActivities);
function gotoActivities (event:MouseEvent):void{
activities.removeEventListener(MouseEvent.CLICK, gotoActivities);
gotoAndPlay(255);
}
或检查currentFrame
activities.addEventListener(MouseEvent.CLICK, gotoActivities);
function gotoActivities (event:MouseEvent):void{
if(this.currentFrame!=255) gotoAndPlay(255);
}