Copy link to clipboard
Copied
I can't come up with a function that will collect the names of the children in a object container and put them in a array.
Any ideas?
For example:
function collectChildren(container:DisplayObjectContainer):Array {
var len:int = container.numChildren;
var array:Array = [];
for (var i:int = 0; i < len; i++)
{
array.push(container.getChildAt(i).name);
}
return array;
}
Copy link to clipboard
Copied
For example:
function collectChildren(container:DisplayObjectContainer):Array {
var len:int = container.numChildren;
var array:Array = [];
for (var i:int = 0; i < len; i++)
{
array.push(container.getChildAt(i).name);
}
return array;
}
Copy link to clipboard
Copied
Thanks a lot Andrei1,
I was trying with the instance of the Array class and failed, I didn't realize it could be done with a function of type Array.
Copy link to clipboard
Copied
You are welcome.
Functions can return any datatype.
Copy link to clipboard
Copied
That :Array you see is not defining the class of the function. It identifies the class of the object returned by the function. That's why in most functions you probably see :void in that spot... identifying that the function doesn't return anything