The AS3 classes generated by Prefab and Away3D also hold a meshes array.
so if you know which one is the target
you also can change your material with
(myclass.meshes[index].material as BitmapMaterial).bitmap =
myNewBitmapdata;
Fabrice
On Nov 30, 2009, at 11:28 AM, lo-th wrote:
Hi
for me the best way to change material is
C_MAP({ obj:your_objet3d, clip:your_Bitmapdata , type:"bitmap",
s:true})
function C_MAP( ini:Object ):void{
MAP( ini ); var mat:*= ini['mat'] ;
ini['mat'].smooth=ini["s"] || false;
var M= ini['obj'] as Mesh
for each (var F:Face in M.faces){ if(F)F.material=mat }
}
// only for primitive object
function C_MAP2( ini:Object ):void{
MAP( ini ); var mat:*= ini['mat'] ;
ini['mat'].smooth=ini["s"] || false;
var M= ini['obj'] as Mesh
M.material=(mat)
}
// material in away lite
public function MAP( ini:Object ):void{
switch(ini['type']){
case "bitmap": ini['mat'] = new BitmapMaterial( ini['clip'] );
break;
case "color": ini['mat'] = new ColorMaterial (ini['color'] ||
0x00 ,ini['alpha'] || 1 ); break;
case "null": ini['mat'] = new ColorMaterial (0x00, 0);break;
case "wire": ini['mat'] = new WireframeMaterial( ini['color'] ||
0x00) break;
case "movie": ini['mat'] = new MovieMaterial(ini['clip']); break;
}}