开发者

for loop in as3

开发者 https://www.devze.com 2023-01-01 06:10 出处:网络
i\'m trying to effect a number of movieclips inside another movieclip, in this case set the alpha to 20%.

i'm trying to effect a number of movieclips inside another movieclip, in this case set the alpha to 20%.

But all i get is an error message. (TypeError: Error #1010: A term is undefined and has no properties. at array_fla::MainTimeline/frame1())

Anyone knows why it's not working?

var myClip = new mcClip;
addChild(myClip);

myCli开发者_如何学Pythonp.x = 270;
myClip.y = 175;


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

(there are five circles on the stage in the myClip movieclip named circle1, circle2, circle3...)


Either make that those 5 circleX an array called circle, or use

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


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

OR

Name the circles movieclips as "circle_1", "circle_2" ... "circle_5" and:

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

精彩评论

暂无评论...
验证码 换一张
取 消