我是Flash和ActionScript 3的初学者 我有一个在不同框架中创建的角色的8个唇码,所以我想逐帧播放动画,但是顺序不同,以形成一个短语,我的角色会说 我确实自己尝试过,但没有成功:
stop();
var tableau = new Array();
tableau[0]=2;
tableau[1]=4;
tableau[2]=1;
tableau[3]=7;
tableau[4]=8;
tableau[5]=1;
tableau[6]=7;
for(var i =0;i<tableau.length;i++){
trace(tableau[i]==this.currentFrame);
if(tableau[i]==this.currentFrame){
gotoAndPlay(tableau[i]);
trace(this.currentFrame);
}
}
答案 0 :(得分:2)
这非常简单。您需要订阅的特殊事件每帧触发一次,并根据计划将播放头移动每帧一次。
stop();
var Frames:Array;
// This will prevent things from overlapping
// if one of the frames on the list is the
// current one and playhead will hit here
// once again (and try to execute code).
if (Frames == null)
{
Frames = [2,4,1,7,8,1,7];
addEventListener(Event.ENTER_FRAME, onFrame);
}
function onFrame(e:Event):void
{
// Get the next frame index and remove it from the list.
var aFrame:int = Frames.shift();
// If there are no more frames to show,
// unsubscribe from the event.
if (Frames.length < 1)
{
removeEventListener(Event.ENTER_FRAME, onFrame);
}
gotoAndStop(aFrame);
}