2010-05-26 75 views
0

我试图影响另一个movieclip内的一些movieclip,在这种情况下,将alpha设置为20%。for循环在as3

但我得到的只是一条错误消息。 (TypeError:Error#1010:Term is undefined and have no properties。at array_fla :: MainTimeline/frame1())

任何人都知道为什么它不起作用?

var myClip = new mcClip; 
addChild(myClip); 

myClip.x = 270; 
myClip.y = 175; 


for (var i:Number = 1; i < 6; i++) { 
trace([i]); 
myClip.circle[i].alpha = .2; 
} 

(有上的myClip阶段五周界影片剪辑命名CIRCLE1,CIRCLE2,CIRCLE3 ...)

回答

1

要么让那些5 circleX阵列称为circle,或使用

myClip["circle" + i].alpha = 0.2; 
+0

Awsome ...谢谢。 – Haljan 2010-05-26 08:39:06

0
for (var i:uint = 0; i < this.numChildren; i++) 
{ 
    this.getChildAt(i).alpha = 0.2; 
} 

OR

名称圆电影剪辑为“circle_1”,“circle_2”...“circle_5”和:

for (var i:uint = 1; i <= 5; i++) 
{ 
    this.getChildByName("circle_" + String(i)).alpha = 0.2; 
}