2014-12-23 37 views

回答

1

比方说,我们有一个影片剪辑 'MCA' MCA包含其他3部影片剪辑'MCB''MCC''麦当劳'。现在 ,我们可以说泰德MCBMCCMCD孩子的MCA 所以如果我们想知道有多少孩子的一个影片剪辑有,我们可以使用movieclip.numChildren。 在我们的例子中,我们有:

mcA.numChildren -> this is equals to 3 
trace(mcA.numChildren); //output 3 
trace(mcB.numChildren); //output 0 

getChildAt是一个参数,表示孩子的索引/层梅托德/功能。 如果图层存在,此方法将返回该索引处的子项。

例如:

mcA : 
     index0- mcC 
     index1 - mcD 
     index2 - mcB 

,如果这是MCA然后的结构:

mcA.getChildAt(0); //this will return mcC 
mcA.getChildAt(1); //this will return mcD 
mcA.getChildAt(2); //this will return mcB 
mcA.getChildAt(3); //this is error 'The supplied index is out of bounds ...' 

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObjectContainer.html#getChildAt();