Create a new fla file and name it GetChildren.fla. Place the fla in the same folder as the biz folder. Add a MovieClip containing two shapes and name it "mc" and add a static TextField. Then create an Actionscript file, name it Getchildren.as and place this script. You should see a trace similar to the one shown below. The error message is legal, since it is caused by a
catch
function.
package
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.events.Event;
import biz.flashscript.utils.GetChildren;
public class Getchildren extends Sprite
{
private var gc:GetChildren;
public function Getchildren ():void
{
var aa:Clip = new Clip();
aa.name = "1";
addChild (aa);
var bb:Clip = new Clip();
bb.x = 200;
bb.name = "2";
addChild (bb);
var cc:TextField=new TextField();
addChild (cc);
cc.name = "3";
gc = new GetChildren(this,this);
addEventListener (GetChildren.DISPLAY_CHILDREN, listChildren);
}
private function listChildren (e:Event):void
{
for (var a=0; a < gc.StageArray.length; a++)
{
trace ("stageChildName: "+gc.StageArray[a].data.name);
trace ("stageChild: "+gc.StageArray[a].label);
}
for (var i=0; i < gc.AddChildArray.length; i++)
{
trace ("addChildValue: "+gc.AddChildArray[i].data.valueOf());
trace ("addChildName: "+gc.AddChildArray[i].data.name);
trace ("addChild: "+gc.AddChildArray[i].label);
}
for (var j=0; j < gc.RegChildArray.length; j++)
{
trace ("regChildValue: "+gc.RegChildArray[j].data.valueOf());
trace ("regChildName: "+gc.RegChildArray[j].data.name);
trace ("regChild: "+gc.RegChildArray[j].label);
}
}
}
}
|