Hey Colir the problem with clone and materials is that material references are kept intact, so the same materials are used for each collada object. This is mainly to save memory, but i guess you could loop through the material library to set all materials to new material instances, and then the colors would be independent of each other
the reason for your null error in the MouesEvent3D listener is that casting all obejcts returned as Mesh will cause nulls where objectcontainers are encountered. you will need to check for this in your listener to avoid errors also, the reason why material properties are null in the mesh is that the collada file is not using them. mesh.material like a global material setter on all geometry in teh mesh, but collada (and a nuber of other formats) only deal with face mateiral properties, so that material inatances are set individually on a face. using the mateiralLibrary object as you do is the easiet way to access collada faces outside the geometry structure hth! Rob On Thu, Jul 23, 2009 at 8:31 AM, Colir <[email protected]> wrote: > > someone can help me please > thanks > > On 21 juil, 18:41, Colir <[email protected]> wrote: > > yo ben, this my code: > > > > var floorGab = Collada.load("floorGab.dae",{autoLoadTextures : > > true,scaling:0.005}); > > floorGab.addOnSuccess(gabLoadSucess) > > function gabLoadSucess(evt:LoaderEvent):void{ > > floorGab = ObjectContainer3D(evt.loader.handle); > > floorGab.position = new Number3D(0,0,0); > > > > for(var i:int=0;i <= nbFloor;i++){ > > floorGab.clone(this["floor"+i]) > > this["floor" + i].name = "floor" + i > > this["floor" + i].y = 20*i > > hospital.addChild(this["floor" + i]) > > this["floor" + i].addOnMouseOver(showFloorInfo); > > this["floor" + i].addOnMouseOut(hideFloorInfo); > > this["floor" + i].addOnMouseUp(getTheFloor); > > this["floor" + i].ownCanvas=true > > } > > > > floorMat = floorGab.materialLibrary.getMaterial("floorID") > > floorMat.material = gabFloorMat; > > } > > > > function showFloorInfo(evt:MouseEvent3D):void{ > > var currentFloor = evt.object as Mesh > > > > currentFloor.mouseEnabled = true > > currentFloor.useHandCursor = true > > > > for(var j:int=0;j<currentFloor.faces.length-1;j++) { > > var fd:Face = currentFloor.faces[j] as Face; > > fd.material = selectedFloorMat; > > } > > > > } > > > > thanks > > > > On 21 juil, 15:43, ben <[email protected]> wrote: > > > > > 1. ok, my fault, the habit of simple MouseEvent, yes this e.object: > > > MouseEvent.target == MouseEvent3D.object > > > > > 2.... well ? show me how you did the whole cloning and colorchange... > -- Rob Bateman Flash Development & Consultancy [email protected] www.infiniteturtles.co.uk www.away3d.com
