AssetLibrary how to use loaded assets?

Software: Away3D 4.x

Ankur, Jr. Member
Posted: 11 February 2013 07:38 PM   Total Posts: 43

I have successfully managed to load an asset and grab the mesh from it. But I want to create many meshes from the same asset. Is that possible? The code below does not work? It only adds 1 model to the scene. Am I doing something wrong?

_athleteMeshArray = new Array();
for (var 
i:int=0i<10i++)
   
{
    _athleteMeshArray[i] 
Mesh(AssetLibrary.getAsset("male"));
     
    
trace("Asset Found");
    
    
_athleteMeshArray[i].castsShadows true;
    
_athleteMeshArray[i].material.lightPicker _lightPicker;
    
_athleteMeshArray[i].= -400;
    
_athleteMeshArray[i].= -107;
    
_athleteMeshArray[i].= -200+xOffset;
    
xOffset +=10;
    
_container.addChild(_athleteMeshArray[i]);
   

Ankur, Jr. Member
Posted: 12 February 2013 11:27 AM   Total Posts: 43   [ # 1 ]

I was experimenting a bit more. The results show up perfectly with this code -

var cube:Geometry = new CubeGeometry(101010);
   var 
geometrySet:Vector.<Geometry> = new Vector.<Geometry>;
   
   for (var 
j:int 01000j++)
   
{
    geometrySet
.push(cube);
    var 
mesh:Mesh = new Mesh(geometrySet[j]);
    
mesh.xOffset;
    
xOffset++;
    
_container.addChild(mesh);
   

But when I change it to this code, it only adds one mesh to the scene, not 100 like it did with the cubes above. -

_athleteMeshVector = new Vector.<Mesh>;
for (var 
i:int=0i<4i++)
   
{
    
var mesh:Mesh;
    
mesh Mesh(AssetLibrary.getAsset("male"));

    
mesh.castsShadows true;
    
mesh.material.lightPicker _lightPicker;
    
mesh.xOffset//-200
    
xOffset +=10;
    
_container.addChild(mesh);
   

So I am pretty sure that it is an AssetLibrary thing, and not a problem with my way of populating the array.

It seems that the assets loaded in asset library can not be duplicated. Is there a way to duplicate the assets from assetLiibrary.

   

John Brookes, Moderator
Posted: 12 February 2013 02:16 PM   Total Posts: 732   [ # 2 ]

You can use the clone() method.

   

Ankur, Jr. Member
Posted: 12 February 2013 03:37 PM   Total Posts: 43   [ # 3 ]
JohnBrookes - 12 February 2013 02:16 PM

You can use the clone() method.

WOW! Works Wonders!

You deserve a medal! +10000

Thanks very much!

   

Ankur, Jr. Member
Posted: 13 February 2013 08:20 AM   Total Posts: 43   [ # 4 ]

clone() method works fine for duplicating meshes. But do you know how I would duplicate Skeletons and SkeletonClipNodes that I loaded in AssetLibrary.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X