Flash,ActionScript 3:获取动画片段中包含的所有动画片段

mat*_*thy 2 iteration flash for-loop actionscript-3

最好说我有一个movieClip A,其中包含movieClips B1,B2,B3,B4,B5

我在A中编写代码来接收所有包含的影片剪辑,并在那里打印名称.

我尝试了这个没有成功:

for each (a:MovieClip in this)
    trace(a.name);
Run Code Online (Sandbox Code Playgroud)

有谁知道如何使这个工作.

**请注意,跟踪名称实际上是一个示例,我希望与对象本身做非常不同的事情,例如更改可见性等等**

谢谢,Matthy

小智 5

我不确定我是否完全理解你要做的事情,但是你可以做一些这样的事情来从父母moielcip中提取他们的实例名称:

for(var i:int = 0; i < target_mc.numChildren; i++) {
trace (target_mc.getChildAt(i).name);
}
Run Code Online (Sandbox Code Playgroud)

您还可以使用更详细的内容提取更多信息,例如对象的类型:

for(var i:int = 0; i < target_mc.numChildren; i++) {
trace ('\t|\t ' +i+'.\t name:' + target_mc.getChildAt(i).name + '\t type:' + typeof 
(target_mc.getChildAt(i))+ '\t' + target_mc.getChildAt(i));
}
Run Code Online (Sandbox Code Playgroud)