作者laugher (打枪(*﹏*))
看板Flash
标题Re: [问题]回圈设值
时间Fri Oct 28 13:43:32 2005
※ 引述《Sibevin (天才艺术家)》之铭言:
: 我在影格中写了一个回圈如下
: var i:Number = 0;
: var chosenPart:Number = 0;
: for (i=1; i<=5; i++) {
: eval("part_"+i+"_mc").onPress = function() {
: chosenPart = i;
: }
: }
: 原本想做成只要选part_1_mc~part_5_mc其中的一块
: chosenPart就会对应到它的号码
: 例如:选part_1_mc,则chosenPart=1;
: 选part_2_mc,则chosenPart=2;
: ...
: 但结果却是
: 选part_1_mc,则chosenPart=6;
: 选part_2_mc,则chosenPart=6;
: ...
: 我可以理解问题出在哪里,因为回圈的结果是
: part_1_mc.onPress = function() {
: chosenPart = i;
: }
: part_2_mc.onPress = function() {
: chosenPart = i;
: }
: ...
: 可是我想要的是
: part_1_mc.onPress = function() {
: chosenPart = 1;
: }
: part_2_mc.onPress = function() {
: chosenPart = 2;
: }
: ...
: 虽然可以不用回圈来解决这个问题
: 但如果要做好几个这种东西
: 显然这个方法不是明智之举
: 要怎样修改程式码才能有我想要的结果
: 请各位帮帮我吧
for (i=1; i<=5; i++) {
eval("part_"+i+"_mc").onPress = function() {
chosenPart = int(this._name.substr(5,1));
}
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.115.48.185
1F:推 Sibevin:瞬间解答我的疑惑~真的非常感谢 10/28 14:31