Actionscript 3 尝试移动到下一帧时出现AS3错误#1009
在我的程序中,我有一个旋转的小箭头,这是我使用的代码Actionscript 3 尝试移动到下一帧时出现AS3错误#1009,actionscript-3,flash,cs3,Actionscript 3,Flash,Cs3,在我的程序中,我有一个旋转的小箭头,这是我使用的代码 import flash.events.Event; var spinSpeed:Number = 2; function onEnterFrame(event:Event):void{ myMovieClip.rotation += spinSpeed; } addEventListener(Event.ENTER_FRAME, onEnterFrame); btnnext14.addEventListener(Mouse
import flash.events.Event;
var spinSpeed:Number = 2;
function onEnterFrame(event:Event):void{
myMovieClip.rotation += spinSpeed;
}
addEventListener(Event.ENTER_FRAME, onEnterFrame);
btnnext14.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_11);
function fl_ClickToGoToAndStopAtFrame_11(event:MouseEvent):void
{
gotoAndStop(39);
}
它工作正常,箭头旋转,但当我尝试转到下一张幻灯片时,我得到一个错误#1009
有人知道出了什么问题吗?这可能是你的问题: 在发布的代码运行的任何帧上,都添加一个enter\u帧侦听器。 您可能不知道,即使更改到第39帧,您创建的此输入帧侦听器仍将继续运行 很可能在第39帧,您的
myMovieClip
对象不再存在,因此当您的onEnterFrame
从第39帧运行时,它会出错
要解决此问题,请在转到第39帧之前删除enter_帧侦听器:
function fl_ClickToGoToAndStopAtFrame_11(event:MouseEvent):void
{
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
gotoAndStop(39);
}
function fl_ClickToGoToAndStopAtFrame_11(event:MouseEvent):void
{
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
gotoAndStop(39);
}