Flash 为什么不是';难道我的动画在继续之前没有等待eventlistener吗?

Flash 为什么不是';难道我的动画在继续之前没有等待eventlistener吗?,flash,actionscript-3,animation,Flash,Actionscript 3,Animation,我的问题是,我不想删除孩子(playPart1);。我要孩子留下来。然而,如果我不把它去掉,一切都会很好。如果我真的删除了它,它似乎忽略了一个事实,即它必须在进入playPart1之前完成playGraph。知道为什么会这样吗 我假设Chart/Part1/Part2是MovieClip符号,在到达最后一帧时发送完整事件?如果这是正确的,那么我可以合理地猜测发生了什么 您假设您的符号将不会播放,直到您将它们添加到舞台并调用gotoAndPlay。这是不正确的,只要您实例化一个符号,它就会开始在后

我的问题是,我不想删除孩子(playPart1);。我要孩子留下来。然而,如果我不把它去掉,一切都会很好。如果我真的删除了它,它似乎忽略了一个事实,即它必须在进入playPart1之前完成playGraph。知道为什么会这样吗

我假设Chart/Part1/Part2是MovieClip符号,在到达最后一帧时发送完整事件?如果这是正确的,那么我可以合理地猜测发生了什么

您假设您的符号将不会播放,直到您将它们添加到舞台并调用gotoAndPlay。这是不正确的,只要您实例化一个符号,它就会开始在后台播放,也就是说,前4行代码将创建符号并开始播放它们,即使它们在屏幕上不可见,因此,您的完整事件将在您预期之前在后台触发

解决方案是在实例化这些符号后立即停止播放,然后在触发上一个完整事件后开始播放

    var playGraph = new Chart();
var playPart1 = new Part1();
var playPart2 = new Part2();
var playPart3 = new Part3(); 

addChild(playGraph);
playGraph.gotoAndPlay(1);
var s1:SoundOne = new SoundOne();
s1.play();

playGraph.addEventListener(Event.COMPLETE, onCompleteGraph); 
playPart1.addEventListener(Event.COMPLETE, onCompletePart1); 
playPart2.addEventListener(Event.COMPLETE, onCompletePart2); 

function onCompleteGraph(evt:Event):void
{
    playPart1.x = 370;
    playPart1.y = 190;
    addChild(playPart1);
    playPart1.gotoAndPlay(1);
}


function onCompletePart1(evt:Event):void
{

    playPart2.x = 100;
    playPart2.y = 100;
    addChild(playPart2);
    playPart2.gotoAndPlay(1);
    var s2:Sound2 = new Sound2();
    s2.play();

}

function onCompletePart2(evt:Event):void
{
    removeChild(playPart2);
    addChild(playPart3);
    playPart3.gotoAndPlay(1);
    var s3:Sound3 = new Sound3();
    s3.play();

}

你能编辑这个部分吗,它很混乱:“我不想删除playPart1。但是-如果我不删除它,一切都会正常播放。如果我删除它,它似乎会跳过Part1”。@sch56 why
playGraph.gotoAndPlay(1)
onCompleteGraph()
它在那里,因为我想按顺序播放这些部分。每个事件侦听器指向一个新电影。
var playGraph = new Chart();
var playPart1 = new Part1();
var playPart2 = new Part2();
var playPart3 = new Part3(); 

//Stop the symbols from playing automatically
playPart1.stop();
playPart2.stop();
playPart3.stop();

addChild(playGraph);
playGraph.gotoAndPlay(1);
var s1:SoundOne = new SoundOne();
s1.play();

playGraph.addEventListener(Event.COMPLETE, onCompleteGraph); 
playPart1.addEventListener(Event.COMPLETE, onCompletePart1); 
playPart2.addEventListener(Event.COMPLETE, onCompletePart2); 

function onCompleteGraph(evt:Event):void
{
    playPart1.x = 370;
    playPart1.y = 190;
    addChild(playPart1);
    playPart1.gotoAndPlay(1);
}


function onCompletePart1(evt:Event):void
{

    playPart2.x = 100;
    playPart2.y = 100;
    addChild(playPart2);
    playPart2.gotoAndPlay(1);
    var s2:Sound2 = new Sound2();
    s2.play();

}

function onCompletePart2(evt:Event):void
{
    removeChild(playPart2);
    addChild(playPart3);
    playPart3.gotoAndPlay(1);
    var s3:Sound3 = new Sound3();
    s3.play();

}