说我有这个AS3代码:
playButtonContainer.addEventListener(MouseEvent.CLICK, playButtonClicked);
function playButtonClicked(evt:MouseEvent) {
instructionsContainer.gotoAndPlay(2);
analysisScreenContainer.gotoAndPlay(2);
playButtonContainer.gotoAndPlay(2);
statusDescriptionContainer.gotoAndPlay(2);
}
在instructionsContainer
内,analysisScreenCnotainer
,playButtonContainer
和statusDescriptionContainer
是一个MovieClip,它有自己的时间轴和动画。
正如你所看到的,我有4个不同的MovieClip一个接一个地播放。我如何做到这一点
statusDescriptionContainer.gotoAndPlay(2);
仅在
的动画之后执行playButtonContainer.gotoAndPlay(2);
完成执行并
playButtonContainer.gotoAndPlay(2);
仅在
之后执行playButtonContainer.gotoAndPlay(2);
动画结束了吗?
答案 0 :(得分:1)
切尔诺夫建议你或者你可以添加一个事件监听器,然后只需要输入框架。在那里,您只需检查currentFrame是否等于totalFrames。或者你可以扩展movieclip:
package {
import flash.display.MovieClip;
import flash.events.Event;
public class AdvancedMovieClip extends MovieClip {
public function AdvancedMovieClip() {
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(e:Event):void {
if(this.currentFrame == this.totalFrames) {
dispatchEvent(new Event(Event.COMPLETE));
}
}
public function destroy():void {
this.stop();
this.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
}
}
答案 1 :(得分:1)
您可以尝试以下方式:
playButtonContainer.addEventListener(MouseEvent.CLICK, playButtonClickedHandler, false, 0, true);
function playButtonClickedHandler(event:MouseEvent):void
{
trace('instructionsContainer');
instructionsContainer.addFrameScript(instructionsContainer.totalFrames -1, playStatusDescriptor);
instructionsContainer.gotoAndPlay(2);
}
function playStatusDescriptor():void
{
instructionsContainer.stop();
trace('statusDescriptionContainer');
statusDescriptionContainer.addFrameScript(statusDescriptionContainer.totalFrames -1, playAnalysisScreen);
statusDescriptionContainer.gotoAndPlay(2);
}
function playAnalysisScreen():void
{
statusDescriptionContainer.stop();
trace('playAnalysisScreen');
analysisScreenContainer.addFrameScript(analysisScreenContainer.totalFrames -1, playAnotherButton);
analysisScreenContainer.gotoAndPlay(2);
}
function playAnotherButton():void
{
analysisScreenContainer.stop();
trace('playAnotherButton');
anotherScreenContainer.addFrameScript(anotherScreenContainer.totalFrames -1, somethingElse);
anotherScreenContainer.gotoAndPlay(2);
}
function somethingElse():void
{
anotherScreenContainer.stop();
trace('somethingElse');
}