I have a sample that compiles in Away3d 3.6 and am trying to convert it to v4. Here is the complete code and I am stuck at the ExplodeAll function. Could anyone tell me how those last 3 lines should be written? On compilation its complaining of the explode.apply part. Thanks in advance for any help. F
package
{
import away3d.containers.ObjectContainer3D;
import away3d.entities.Mesh;
import away3d.events.MouseEvent3D;
import away3d.lights.PointLight;
import away3d.materials.lightpickers.StaticLightPicker;
import away3d.materials.ColorMaterial;
import away3d.primitives.SphereGeometry;
//import away3d.test.Button;
import away3d.tools.commands.Explode;
import away3d.core.base.Object3D;
import com.greensock.TweenMax;
import com.greensock.easing.Linear;
import flash.events.MouseEvent;
import flash.geom.Vector3D;
[SWF(backgroundColor=”#677999”, frameRate=“30”, quality=“LOW”, width=“800”, height=“600”)]
public class SimpleExplode extends AwayTemplate
{
private var explodeContainer:ObjectContainer3D;
private var sphere:SphereGeometry;
private var light:PointLight;
protected var lightPicker:StaticLightPicker;
private var colShade:ColorMaterial;
private var canReset:Boolean=false;
private var object3D:Object3D;
public function SimpleExplode()
{
super();
cam.z=-1000;
initLight();
initGUI();
}
override protected function initGeometry() : void{
setGeometry();
}
override protected function initMaterials():void{
colShade=new ColorMaterial(0xFD2D2D);
//colShade.shininess=3
colShade.specular=2.4;
colShade.ambient=0x127623;
}
override protected function initListeners():void{
super.initListeners();
view.addEventListener(MouseEvent3D.MOUSE_DOWN,explodeAll);
}
private function initLight():void{
light = new PointLight();
light.ambient=0.25;
light.color = 0xCCCCCC;
lightPicker = new StaticLightPicker([light]);
}
private function setGeometry():void{
var sphere:SphereGeometry = new SphereGeometry(250);
var mesh:Mesh = new Mesh(sphere, colShade);
view.scene.addChild(mesh);
}
private function explodeAll(e:MouseEvent3D):void{
//////remove light for performance reason///////////////
//view.scene.removeLight(light);
var explode:Explode = new Explode();
unicmeshes:true;
recenter:true;
//Am Stuck with the last 3 lines of this
//public function apply(object3d:Object3D):Object3D
//explodeContainer = explode.apply(sphere) as ObjectContainer3D
//view.scene.addChild(explodeContainer);
//view.scene.removeChild(sphere);
for each(var item:Mesh in explodeContainer.numChildren)
{
item.scaleX = 0.5;
//item.bothsides=true;
var vector:Vector3D=item.position;
TweenMax.to(item,25,{x:vector.x*(25+Math.random()*1000-500),y:vector.y*(25+Math.random()*1000-500),z:vector.z*(25+Math.random()*1000-500), ease:Linear.easeOut, onComplete:deleteTri,onCompleteParams:[item]});
TweenMax.to(item,12,{rotationX:Math.random()*3000-1500,rotationY:Math.random()*3000-1500,rotationZ:Math.random()*3000-1500});
}
//canReset=true;
}
private function initGUI():void{
//var button:Button = new Button(“reset”);
//this.addChild(button);
//button.x=100;
//button.y=50;
//button.addEventListener(MouseEvent.CLICK,onButtonClick);
}
private function onButtonClick(e:MouseEvent):void{
//if(canReset){
//resetGeometry();
//canReset=false;
//}
}
private function resetGeometry():void{
//view.scene.removeChild(sphere);
//sphere=null;
///////////deep cleanup////////////////////
/*for(var i:int=0;i