flash as 2.0 的for循环问题
slt.swfbtn1.onRelease=function(){loadMovie("ffcl/flash/f1.swf","swf");mScene._alpha=0...
slt.swfbtn1.onRelease = function() {
loadMovie("ffcl/flash/f1.swf","swf");
mScene._alpha = 0 ;
gb._alpha = 100 ;
}
slt.swfbtn2.onRelease = function() {
loadMovie("ffcl/flash/f2.swf","swf");
mScene._alpha = 0 ;
gb._alpha = 100 ;
}
slt.swfbtn3.onRelease = function() {
loadMovie("ffcl/flash/f3.swf","swf");
mScene._alpha = 0 ;
gb._alpha = 100 ;
}
想把这一段代码用for语句表现出来,不知道怎么写呢?我是这样写的,可是运行不了。
for (i=1; i<=52; i++) {
slt.swfbtn[i].onRelease = function() {
loadMovie("ffcl/flash/f[i].swf","swf");
swf._xscale = 94 ;
swf._yscale = 94 ;
mScene._alpha = 0 ;
gb._alpha = 100 ;
}
}
哪里不对呐? 展开
loadMovie("ffcl/flash/f1.swf","swf");
mScene._alpha = 0 ;
gb._alpha = 100 ;
}
slt.swfbtn2.onRelease = function() {
loadMovie("ffcl/flash/f2.swf","swf");
mScene._alpha = 0 ;
gb._alpha = 100 ;
}
slt.swfbtn3.onRelease = function() {
loadMovie("ffcl/flash/f3.swf","swf");
mScene._alpha = 0 ;
gb._alpha = 100 ;
}
想把这一段代码用for语句表现出来,不知道怎么写呢?我是这样写的,可是运行不了。
for (i=1; i<=52; i++) {
slt.swfbtn[i].onRelease = function() {
loadMovie("ffcl/flash/f[i].swf","swf");
swf._xscale = 94 ;
swf._yscale = 94 ;
mScene._alpha = 0 ;
gb._alpha = 100 ;
}
}
哪里不对呐? 展开
1个回答
展开全部
应该是这样:
for (i=1; i<=52; i++) {
slt["swfbtn"+i].onRelease = function() {
loadMovie("ffcl/flash/f"+i+".swf","swf");
swf._xscale = 94 ;
swf._yscale = 94 ;
mScene._alpha = 0 ;
gb._alpha = 100 ;
}
}
swfbtn不是一个数组,所以
swfbtn[i]是错的
同现,f[i]也不是数据,而是一个拼接的字符串才对
for (i=1; i<=52; i++) {
slt["swfbtn"+i].onRelease = function() {
loadMovie("ffcl/flash/f"+i+".swf","swf");
swf._xscale = 94 ;
swf._yscale = 94 ;
mScene._alpha = 0 ;
gb._alpha = 100 ;
}
}
swfbtn不是一个数组,所以
swfbtn[i]是错的
同现,f[i]也不是数据,而是一个拼接的字符串才对
追问
这样写了,为什么还是调用不到呢?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询