2009-07-09

Using an Embedded Flex Image in Papervision3D

One of the problems had setting up the demo in the previous post was using embedded flex images for materials in the Papervision 3D scene, here is the solution. Create a variable for with the embedded image and the variable for the material.
[Embed(source="assets/earthmap.jpg")]
public var earthMap:Class;
private var moonMaterial:BitmapMaterial;

Create a new BitmapAsset variable cad cast the image class to it.

var earthAsset:BitmapAsset = new earthMap() as BitmapAsset;

Finally assign the new variable as a material.

earthMaterial = new BitmapMaterial(earthAsset.bitmapData);

No comments:

Post a Comment