Flashscript classes (ActionScript 3) | Home | MX | MX 2004 | Flash 8 | Flash 9 |Flash 10 |PHP |Components | Snippets | Contact |

GetChildren

Package:
Class:
Inheritance:
biz.flashscript.utils
public class GetChildren
N/A
The GetChildren class allows to trace the children of an object and their subchildren. It can be distinguished between objects directly placed or those used using addChild. For those names should be given, which are numbers. To create a background use the constructor new GetChildren() and add parameters as desired. The first parameter is the object to determine the number of children and the second is the one to dispatch the event to. Three arrays can be traced: stageArray, for children of the stage, addChildArray, for children added using addChild() and regChildArray for children placed directly. Two parameters can be retrieved: Array[].label and Array[].data. The label parameter is a string, whyle the data parameter gives the actual object.
Public Methods
Method Defined By
GetChildren(target:Object, targetDispatch:Object) GetChildren
Events
Event Defined By

displayChildren

This event is dispatched when search for objects is completed.

GetChildren
Constructor Detail
GetChildren ()  Constructor
public function GetChildren(target:Object, targetDispatch:Object)
Intializes a new GetChildren instance with the specified parameters.

Parameters

  • target:Object ____ The object to search children from.
  • targetDispatch:Object ____ The object to dispatch the event to.
Event Detail

displayChildren event

Event Object Type: biz.flashscript.utils.GetChildren
Event.type property = biz.flashscript.components.utils.GetChildren.DISPLAY_CHILDREN

Dispatched when the search is finished.

Examples
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);
			}
		}
	}
}