thanks, John, but it still throws Call to a possibly undefined method
addMethod . A weird thing I just noticed on traces is I get this:

trace(mesh.material);  -- shows [object BitmapMaterial]
trace(mesh.material.name); -- shows the name of the material parsed in
from the 3DS file

but

trace(AssetLibrary.getAsset(mesh.material.name)); -- shows
"null"  ????

On May 31, 3:06 pm, John Brookes <[email protected]> wrote:
> maybe
> BitmapMaterial(mesh.material).addMethod(new EnvMapMethod(cubeMap, 0.5))
>
> On 31 May 2011 20:58, Choons <[email protected]> wrote:
>
>
>
>
>
>
>
> > I'm trying to add an EnvMapMethod onto materials parsed in Broomstick
> > through the Max3DS parse but can't get it to work.
>
> > I think I have the needed class imports to use the method:
>
> > import away3d.materials.utils.CubeMap;
> > import away3d.materials.BitmapMaterial;
> > import away3d.materials.methods.EnvMapMethod;
> > import away3d.primitives.SkyBox;
>
> > I'm using RESOURCE_COMPLETE event:
>
> > AssetLibrary.addEventListener(LoaderEvent.RESOURCE_COMPLETE,
> > onResourceComplete);
>
> > In the onResourceComplete function I get the mesh by the name I
> > assigned:
>
> > var mesh:Mesh = AssetLibrary.getAsset(meshName) as Mesh;
>
> > if I trace(mesh.material) it returns object BitmapMaterial but if I do
> > this:
>
> > mesh.material.addMethod(new EnvMapMethod(cubeMap, 0.5));
>
> > I get Error: Call to a possibly undefined method addMethod through a
> > reference with static type away3d.materials:MaterialBase.
>
> > So then I tried to cast it into a BitmapMaterial variable explicitly
> > with:
>
> > var material:BitmapMaterial =
> > AssetLibrary.getAsset(mesh.material.name) as BitmapMaterial;
> > material.addMethod(new EnvMapMethod(envMap, 0.5));
>
> > Error #1009: Cannot access a property or method of a null object
> > reference
>
> > Anyone know what is going wrong here?

Reply via email to