getChildByName in ObjectContainer3D

Software: Away3D 4.x

proyb2, Newbie
Posted: 28 October 2011 06:49 AM   Total Posts: 17

I found this function is available in Away 3.6 but not implemented Away version 4, is it possible to add getChildByName api into the current release?

   

Avatar
Apprentice, Jr. Member
Posted: 28 October 2011 11:32 AM   Total Posts: 45   [ # 1 ]

I suppose you could add something like this in ObjectContainer3D.as:

public function getChildByName(aName String) : ObjectContainer3D
{
 
for each (var tChild ObjectContainer3D in _children)
 
{
  
if (tChild.name == aName) return tChild;
 
}
 
return null;

Or if you don’t want to change Away3D code, you could also use this in your own code:

public function getChildByName(aYourObject ObjectContainer3DaName String) : ObjectContainer3D
{
 
for (var int 0aYourObject.numChildren; ++i)
 
{
  
if (aYourObject.getChildAt(i).name == aName) return aYourObject.getChildAt(i);
 
}
 
return null;

—Apprentice

   

Avatar
Apprentice, Jr. Member
Posted: 28 October 2011 11:33 AM   Total Posts: 45   [ # 2 ]

Looks like Piwie beat me to it raspberry

   

proyb2, Newbie
Posted: 28 October 2011 12:00 PM   Total Posts: 17   [ # 3 ]

Hey, you know what? I doing the same things as you guys too! I just thought there a more efficient code. So these is good enough? P.S. I’m not an expert in Actionscript.

   

Richard Olsson, Administrator
Posted: 28 October 2011 09:03 PM   Total Posts: 1192   [ # 4 ]

Methods like these will be added in the next release probably. It is not yet decided, but it might be accompanied by a slightly more powerful iterator API (compare to the one in the AssetLibrary), to iterate over all nodes in a branch of the scene graph, search by name, iterate by type et c.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X