Hello,
Been looking at source code for (Basic09_BitmapMaterialExplorer.as).
Want to swap textures back and forth on an .obj ... not quite working,
though ...
Flex framework brought into project library ... CS4, away3d 3.3.3 ...
Import relavent away3d classes:
import away3d.core.utils.Cast;
import away3d.materials.BitmapMaterial;
I embed a couple of textures:
[Embed(source="assetts/teapot_1.jpg")]
public var texture1:Class;
[Embed(source="assetts/teapot_2.jpg")]
public var texture2:Class;
Declare material variables:
private var material1:BitmapMaterial;
private var material2:BitmapMaterial;
Load in .obj:
var obj1:Object3DLoader = Obj.load("assetts/teapot_1.obj",
{material:texture1});
On success grab handle:
obj1object3d = e.loader.handle;
Create new materials:
material1 = new BitmapMaterial( Cast.bitmap( new this[texture1]() as
Bitmap ));
material2 = new BitmapMaterial( Cast.bitmap( new this[texture2]() as
Bitmap ));
On button press simply toggle materials with these calls:
obj1object3d.material = material1;
or
obj1object3d.material = material2;
But get error for the toggle material calls ...
1119: Access of possibly undefined property material through a
reference with static type away3d.core.base:Object3D.
Obviously for a primitive sphere.material works but for Object3D I
have to get it another way ... how would I do that?
BTW, all these things I'm learning I'm compiling into a "Common Noob
Mistakes" to help others as low level as I ...