Add a child to an ObjectContainer3D and name it?

Software: Away3D 4.x

Mr Margaret Scratcher, Sr. Member
Posted: 08 July 2011 01:27 AM   Total Posts: 344

Hi there, trying to add a number of children to an ObjectContainer3D and name them at the same time, so I can reference them easily later on.

In papervision I could just do:

shelfSet.addChildpobjName 

which would add the object ‘p’ to ‘shelfset’ and call it ‘objName’

However in Away3d (I’m using broomstick), it seems that addChild only accepts one argument, so I’m wondering how I can do this?

If I do a count of children,  could I reference that child number?

   

Stephen Hopkins, Sr. Member
Posted: 08 July 2011 02:10 AM   Total Posts: 110   [ # 1 ]

I think so, you can use shelfSet.numChildren, and shelfSet.getChildAt(#)

 Signature 

http://www-scf.usc.edu/~shopkins

   

Mr Margaret Scratcher, Sr. Member
Posted: 08 July 2011 02:18 AM   Total Posts: 344   [ # 2 ]

I’ll give it a go…
smile

   

Richard Olsson, Administrator
Posted: 08 July 2011 08:25 AM   Total Posts: 1192   [ # 3 ]

Or you can just set the name separately:

p.name = objName;

But it’s always better to store a proper reference to the 3D object (i.e. keep the “p” variable around), which will always be faster than look-up by name or index.

   

Mr Margaret Scratcher, Sr. Member
Posted: 08 July 2011 12:10 PM   Total Posts: 344   [ # 4 ]

Sooo… once you’ve named an object, can you do GetChildByName, or similar?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X