我有一个项目,它有 30-40 帧,每帧都有影片剪辑。把每一帧想象成一张幻灯片。舞台底部有控制这些幻灯片功能的按钮(例如播放、暂停、下一个、上一个、加速、减速和刷新)。但是,让我头疼的两个按钮是手动模式和自动模式按钮。他们的名字正是他们的声音,手动应该在每个 mc 在每一帧播放后停止。自动应该按顺序播放每一帧。我现在设置它的方式是每个 mc 触发一个“完成”和“停止”的 EventDispatch。根据最后单击的按钮,舞台将侦听事件并暂停 4 秒 (setInterval) 并转到NextFrame,或者在该帧上停止,直到用户单击下一步。我试过一个开关盒,
我是新手,所以要温柔。如果有帮助,我会上传 flv。非常非常非常感谢。
//Manual button actions
function manual_onClick(event:MouseEvent)
{
manual_btn.visible = false;
auto_btn.visible = true;
gotoAndStop(currentFrame);
stage.removeEventListener("finished", mcFinished);
stage.addEventListener("stopped",stopmc,false,0);
function stopmc(e:Event):void
{
trace("mc stop");
stage.removeEventListener("stopped",stopmc);
}
}
//Auto button actions
function auto_onClick(event:MouseEvent)
{
gotoAndStop(currentFrame + 1);
manual_btn.visible = true;
auto_btn.visible = false;
stage.addEventListener("finished", mcFinished2,false,1);
function mcFinished2(e:Event):void
{
var ID2 = setInterval(goNextFrame2,3000);
trace("mc complete");
function goNextFrame2()
{
gotoAndStop( currentFrame + 1 );
clearInterval( ID2 );
stage.removeEventListener("finished", mcFinished2);
}
}
}
以及来自每个 mc 的 dispatchEvent
stop();
dispatchEvent(new Event("finished", true));
dispatchEvent(new Event("stopped", true));
再次感谢!斯科特
这是开关盒尝试...
function onBtnClicked(evt:MouseEvent):void
{
var theBtn:DisplayObject = evt.currentTarget as DisplayObject;
var lastBtn:DisplayObject;
if (lastBtn)
{
lastBtn.addEventListener(MouseEvent.CLICK, onBtnClicked);
}
lastBtn = theBtn;
switch (theBtn)
{
case auto_btn :
//button one actions;
gotoAndStop(currentFrame + 1);
manual_btn.visible = true;
auto_btn.visible = false;
trace("auto button clicked");
stage.addEventListener("finished", mcFinished);
function mcFinished(e:Event):void
{
var ID = new setInterval(goNextFrame,3000);
trace("mc complete");
function goNextFrame()
{
gotoAndStop( currentFrame + 1 );
clearInterval( ID );
stage.removeEventListener("finished", mcFinished);
stage.addEventListener("finished", mcFinished);
}
}
break;
case manual_btn :
manual_btn.visible = false;
auto_btn.visible = true;
trace("manual button clicked");
stage.removeEventListener("finished", mcFinished);
stage.addEventListener("stopped",stopmc,false,1);
function stopmc(e:Event):void
{
trace("mc stop");
stage.addEventListener("stopped",stopmc);
stage.removeEventListener("stopped",stopmc);
}
break;
}
}