2009-12-23 55 views
0

我有一个精灵,在其中我添加了其他精灵。 喜欢的东西:控制精灵的子精灵的属性

var sp_main:Sprite = new Sprite(); 
var sp_group:Sprite = new Sprite(); 

for(i:int = 0; i < 10; i++) 
{ 
    var temp:Sprite = new Sprite(); 

    sp_group.addChild(temp); 
} 

sp_main.addChild(sp_group); 

//this part doesn't seem to work... i don't mind doing it another way, but 
//am unaware of one. 
sp_main["sp_group"].alpha = 0.0; 

,我怎么可能做到这一点或类似的东西有什么想法?

回答

3
sp_main.getChildAt(0).alpha = 0; 

(假定sp_main仅包含sp_group)。

sp_main.getChildAt(sp_main.getChildIndex(sp_group)).alpha = 0; 

或者(如果你已经命名sp_group)

sp_group.name = "sp_group"; 
sp_main.getChildByName("sp_group").alpha = 0; 
+0

大;谢谢。我使用了更多的AS2语法。 :p – jml 2009-12-23 05:40:52