calling Objects by Name

Software: Away3D 4.x

progressivity, Newbie
Posted: 20 March 2013 01:00 PM   Total Posts: 7

Hi Community,

i try to call some cubes i generate through a loop by a variable cube.name = “cube”+var for tweening.

for (var cubePerB:Number 1cubePerB <= katButtonsCount 1cubePerB++)
{
 cube 
= new Mesh(new CubeGeometry(505050111true) , redMaterial);
 
scene.addChild(cube);
cube.name "cube"+cubePerB;
 
TweenLite.to(cube6{ x:Math.random () * 400y:Math.random () * 400z:Math.random () * 400onCompleterandomAnimationCubes } );

the initial Animation works - and i understand why - but if im trying to call them after generating by the name the Tweener doesnt recognize them.

can somebody explain me why ?

   

aeki, Member
Posted: 21 March 2013 07:30 AM   Total Posts: 73   [ # 1 ]

Use AssetLibrary.

When creating our mesh, use the AssetLibrary.addAsset method.

Then you will be able to them get back by using AssetLibrary.getAsset.

   

progressivity, Newbie
Posted: 21 March 2013 09:19 AM   Total Posts: 7   [ # 2 ]

Ah great, ill have to work with the AL then - do you have some little tutorial lying arround for the usage?

thanks!!

   

aeki, Member
Posted: 21 March 2013 02:31 PM   Total Posts: 73   [ # 3 ]

Maybe you could have a look at this document

   

progressivity, Newbie
Posted: 21 March 2013 02:41 PM   Total Posts: 7   [ # 4 ]

Thanks again aeki!

   

progressivity, Newbie
Posted: 21 March 2013 03:07 PM   Total Posts: 7   [ # 5 ]

for anyone whos interested, it did it the other way:

private var cube1:Mesh;
   private var 
cube2:Mesh;
   private var 
cube3:Mesh;
   private var 
cube4:Mesh;
   private var 
cube5:Mesh;
   private var 
cube6:Mesh;

   for (var 
cubePerB:Number 1cubePerB <= katButtonsCount 1cubePerB++)
   
{    
    this[
'cube' cubePerB] triCW.clone() as Mesh;
    
scene.addChild(this['cube' cubePerB]);
    
this['cube' cubePerB].this['cube' cubePerB].this['cube' cubePerB].Math.random () * 700;
   

the only “problem” is that you have to define the vars/range youre generating, a real dynamic way may comes through using the Library.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X