2010-01-27 68 views
1

我有一個空的movieclip容器,我在其中添加了作爲兒童的動畫片段。但是,當我試圖讓孩子們不追蹤/返回任何東西。這是我的代碼。Flash Movieclips兒童迷失

// Creating Container 
var competencyContainer:MovieClip = new MovieClip(); 
competencyContainer.name = "competencyContainer"; 
this.addChild(competencyContainer); 

var lastx:Number = 200; 
function createUsers(){ 

// Creating movieclips 
for (var i:Number=0; i<globals.scoreList.length;i++) 
{ 
    var test:MovieClip = new userbox(); 
    test.x= lastx; 
    lastx = lastx+104.3;  
    test.name = String(i); 
    competencyContainer.addChild(test); 
} 

} 

function moveRight(eventObject:MouseEvent){ 

trace("right Pressed"); 
trace(competencyContainer); 
for(var childName in competencyContainer){ 
    trace("child movieclip: " + competencyContainer[childName]); 

} 

影片剪輯在屏幕上完美製作,不會出錯。上面的代碼運行。但不顯示

trace("child movieclip: " + competencyContainer[childName]); 

回答

1

這似乎工作:

​​
+0

+1這是正確的做法。 – Amarghosh 2010-01-27 09:47:12

+0

謝謝Ararghosh :) – 2010-01-27 15:18:39

1

您應該使用getChildByName功能...

trace("child movieclip: " + competencyContainer.getChildByName(childName)); 
+0

做到這一點我後來添加的痕跡。首先,我正在通過getChildByName來改變它們的X座標,這是不起作用的。 – 2010-01-27 08:30:41