Heya folks! I've loaded a DAE object and then cloned it 8 times to
make up the eight pie-pieces of a sort of raffle wheel. Unfortunately
when I try to update the material in the materialsLibrary of the 8
newly created objects, I find that the libraries are null, that hasn't
been cloned.

Further, if I change the material in the original object from which
the new objects have been cloned, it updates all the objects. It looks
as though we don't have a true clone, but rather a cloned mesh with a
material reference. Is there any way I can change the bitmapMaterial
on each of these objects? Thanks in advance, guys!

       for(var i:int=0; i<PIECE_COUNT; i++) {
            var pieceCopy:Object3D = piece.clone() as Object3D;
            pieceCopy.rotationY = i*PIECE_ANGLE;

           var pieceMaterial:MaterialData =
piece.materialLibrary.getMaterial("pie_health");
          ///Dynamically grab our material, one of several in the fla's
symbol library.
          var matClass:Class = Class(getDefinitionByName("Piece"+
_pieceNames[i] + "Mat"));

          ///Here i've tried creating a new material library to counter the
null library - it's contents are ignored however.
          pieceCopy.materialLibrary = new MaterialLibrary();
          pieceCopy.materialLibrary.addMaterial("pie_Health");
          (pieceCopy.materialLibrary.getMaterial("pie_Health") as
MaterialData).material = new BitmapMaterial(new matClass(512,512));

          /// If I do the following instead, all the objects get the
last assigned material:
          ///(piece.materialLibrary.getMaterial("pie_Health") as
MaterialData).material = new BitmapMaterial(new matClass(512,512));

          view.scene.addChild(pieceCopy);
      }

Reply via email to