开发者

AS3: How to add linkage in array?

I'm new to AS3 so pl开发者_如何学运维ease excuse me if the question is a bit confusing.

I have 3 movieclips in my library with the Linkage names "Panel1", "Panel2" and "Panel3".

I want to create a new Array on my main timeline with the three movieclips.

i.e. var panelArray = new Array(Panel1, Panel2, Panel3);

How would I be able to do that?


if you want to add the movieClips to array then:

var panelArray = new Array( new Panel1 (), new Panel2 (), new Panel3 ());

and you will be able to access them like:

panelArray[0] // for Panel1;
panelArray[1] // for Panel2;
panelArray[2] // for Panel3;

if you need to add just class name to the array as you did it is good:

var panelArray = new Array(Panel1, Panel2, Panel3);

And when you want access them:

new panelArray[0] () // for Panel1;
new panelArray[1] () // for Panel2;
new panelArray[2] () // for Panel3;

In the first array, the mc's are created on adding them to the array, and when you accessing them you get the DisplayObject directly. In the second array the array holds just a names of the classes, from which you can create a DisplayObject for futher uses.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜