well I found a hackish work around: var hack_material:BitmapMaterial = new BitmapMaterial(); hack_material = mesh.material as BitmapMaterial; hack_material.addMethod(new EnvMapMethod(envMap, 0.5)); mesh.material = hack_material;
apparently the addMethod property hasn't been implemented onto BitmapMaterial materials that are parsed in through the AssetLibrary so you kinda have to give it a "reacharound" 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?
