flash as3获得舞台的显示对象
代码如下:
testDisplayObject(stage);
function testDisplayObject(doc:DisplayObjectContainer)
{
if (doc.numChildren)
{
trace("当前对象",doc,"名字",doc.name,"下有",doc.numChildren,"个子显示对象\n");
for (var j:int=0; j<doc.numChildren; j++)
{
trace("分别是 ",j,":",doc.getChildAt(j),"\t名字是:",doc.getChildAt(j).name);
}
trace("\n\n\n");
for (var k:int=0; k<doc.numChildren; k++)
{
arguments.callee(doc.getChildAt(k));
}
}
else
{
trace("当前对象",doc,"名字",doc.name,"下没有子显示对象了");
}
}
function testDisplayObject(doc:DisplayObjectContainer)
{
if (doc.numChildren)
{
trace("当前对象",doc,"名字",doc.name,"下有",doc.numChildren,"个子显示对象\n");
for (var j:int=0; j<doc.numChildren; j++)
{
trace("分别是 ",j,":",doc.getChildAt(j),"\t名字是:",doc.getChildAt(j).name);
}
trace("\n\n\n");
for (var k:int=0; k<doc.numChildren; k++)
{
arguments.callee(doc.getChildAt(k));
}
}
else
{
trace("当前对象",doc,"名字",doc.name,"下没有子显示对象了");
}
}