I’m loading 3ds object in my scene.
On buttonClick I need to switch the model material between wireframe and loaded one.
Switch to wireframe materials goes normal, but switching back - here’s trouble
//saving default materials
d:Object = new Object();
for each(var _md:MaterialData in model.materialLibrary)
{
d[_md.name] = _md.material;
}
// switching
_wire = !_wire;
var _md:MaterialData;
var m:Material = new WireFrameMaterial(0x0000FF, {thickness:1});
if (_wire)
{
for each (_md in model.materialLibrary)
{
_md.material = m; // here's ok
}
}
else
{
for each (_md in model.materialLibrary)
{
m = d[_md.name];
_md.material = m; //here's error
}
But it works if materialLibrary.length=1 (only one material loaded).
There’s mistake? Thanks