【发布时间】:2013-12-07 23:51:24
【问题描述】:
我在 Edge Animate 中工作。
我试图将符号放置在 2 个不同的地方,当我生成它们时,我总是缺少一个符号。
我还希望能够将前 3 个数字放在他们自己的容器中 - 如果数字是 2,它应该放在 location1[1],如果数字是 8,它应该放在 location1[7]。我不知道如何才能做到这一点。
numbers 数组包含编号为 1、2、3、4、5、6、7、8、9、10 的符号名称。
location1 是一个数组,其中包含每个可能的 3 个数字的容器名称。
其余的容器将变成可放置的。
location2 是一个数组,其中包含将成为可拖动的剩余数字的容器名称。
这是我的代码:
var numbers = ['num1','num2','num3','num4','num5','num6','num7','num8','num9','num10'];
var location1 = ['c1','c2','c3','c4','c5','c6','c7','c8','c9','c10'];
var location2 = ['circle0','circle1','circle2','circle3','circle4','circle5','circle6','circle7','circle8','circle9'];
//randomize numbers
var placedNumbers = numbers.sort(function() {return 0.5 - Math.random()});
// place the 3 first numbers on the top list.
for (i=0;i<3;i++){
sym.createChildSymbol(placedNumbers[i],location1[i]);
}
// place the rest of the numbers in the bottom list
for (j=3;j<11;j++){
sym.createChildSymbol(placedNumbers[j],location2[j]);
}
【问题讨论】:
标签: javascript random adobe-edge