0

I have an animation created in Edge that I need to play 3 times and then stop on a specific frame. I'm new to javascript and I think I need to use a variable and if/else statement, but am unsure what to use and how to write it. Any help would be much appreciated. Thank you!

4

1 回答 1

4

我很不情愿地回复,你真的需要提供一些代码来展示你的尝试。但是,由于这是一个有用的入门问题,我将尝试回答。

您需要的第一件事是一个全局范围的变量来存储循环计数器。在 Stage.compositionComposition 函数中添加类似的内容。

// Add a numLoops variable to global storage
sym.setVariable("numLoops", 0);

接下来,在动画结束时,通过 Timelines 操作,创建一个事件来捕获该变量、递增和重播动画(如果适用),如下所示:

// capture numLoops variable and increment the counter
var numLoopsHolder = sym.getVariable("numLoops");
numLoopsHolder = numLoopsHolder + 1;

// set new numLoops variable back to global storage
sym.setVariable("numLoops", numLoopsHolder);

if (numLoopsHolder <= 2) {
    // replay scene until 3 iterations are complete
    sym.play(0);
}

这将使其循环 3 次,但您仍需要通过以下方式在所需的时间线位置添加停止检查:

// capture numLoops variable to check for 3 loops (ie. 0, 1, 2 = 3 loops)
var numLoopsHolder = sym.getVariable("numLoops");

if (numLoopsHolder >= 2) {
    // we've completed 3 loops now stop here
    sym.stop();
}

这是动作事件参考的时间线屏幕截图。 在此处输入图像描述

于 2013-11-01T14:27:55.123 回答