Hello!
I’m trying to add a mesh from 3DS to Away3D, and i made it work before in another project. But i surely have forgotten something, since i’m trying again in another and i keep getting this Error:
AARun3\src\away3d\animators\states\AnimationClipState.as, Line 172 1067: Implicit coercion of a value of type away3d.animators.states:AnimationClipState to an unrelated type away3d.animators:IAnimationState.
I looked lots of times and I cant find a difference with the other code or anything different. I’ll show you the code, i appreciate your time.
package {
import flash.display.MovieClip;
import away3d.containers.Scene3D;
import away3d.cameras.Camera3D;
import away3d.containers.View3D;
import flash.media.Camera;
import flash.geom.Vector3D;
import flash.events.Event;
import away3d.entities.Mesh;
import away3d.primitives.CubeGeometry;
import away3d.materials.ColorMaterial;
import away3d.textures.BitmapTexture;
import away3d.materials.TextureMaterial;
import away3d.lights.DirectionalLight;
import away3d.lights.PointLight;
import away3d.materials.lightpickers.StaticLightPicker;
import away3d.materials.methods.FilteredShadowMapMethod;
import away3d.primitives.PlaneGeometry;
import away3d.primitives.SphereGeometry;
import away3d.containers.ObjectContainer3D;
import away3d.loaders.Loader3D;
import away3d.loaders.misc.AssetLoaderContext;
import flash.display.Loader;
import away3d.events.AssetEvent;
import flash.net.URLRequest;
import away3d.loaders.parsers.*;
import away3d.library.assets.*;
import jiglib.physics.RigidBody;
import jiglib.plugin.away3d4.Away3D4Physics;
import jiglib.plugin.away3d4.*;
import flash.events.*;
import flash.utils.Timer;
import away3d.controllers.HoverController;
public class Run3 extends MovieClip
{
//Embeds
[Embed(source="txt/road.jpg")]
private var roadT:Class;
//Engine Variables
public var view:View3D;
public var cam:Camera3D;
public var scene:Scene3D;
//Camera Controllers
public var camCnt:HoverController;
//3D Loaders
public var meshLd:Loader3D;
public var suelo:Mesh;
public var suelo2:Mesh;
public var sueloM:TextureMaterial;
public var car:Mesh;
public var i:int;
//navigation variables
private var move:Boolean = false;
private var lastPanAngle:Number;
private var lastTiltAngle:Number;
private var lastMouseX:Number;
private var lastMouseY:Number;
public function Run3()
{
addEngine();
addElements();
addLights();
addListeners();
addGUI();
}
public function addEngine():void
{
scene = new Scene3D();
cam = new Camera3D();
view = new View3D();
view.antiAlias = 4;
view.scene = scene;
view.camera = cam;
stage.addChild(view);
//setup camera Controller
camCnt = new HoverController(cam);
camCnt.distance = 500;
camCnt.minTiltAngle = 0;
camCnt.maxTiltAngle = 90;
camCnt.panAngle = 0;//45
camCnt.tiltAngle = 20;
}
public function addElements():void
{
sueloM = new TextureMaterial(Cast.bitmapTexture(roadT));
sueloM.repeat = true;
sueloM.mipmap = false;
suelo = new Mesh(new PlaneGeometry(200,200), sueloM);
suelo.geometry.scaleUV(2,2);
suelo.y = 0;
scene.addChild(suelo);
suelo2 = new Mesh(new PlaneGeometry(200,200), sueloM);
suelo2.geometry.scaleUV(2,2);
suelo2.y = 0;
suelo2.z = 200;
scene.addChild(suelo2);
loading3DMesh();
}
//addElements related funcs
public function loading3DMesh():void
{
Parsers.enableAllBundled();
var parseador:AssetLoaderContext = new AssetLoaderContext();
Loader3D.enableParser(Max3DSParser);
meshLd = new Loader3D();
meshLd.addEventListener(LoadEvent.RESOURCE_COMPLETE, loaderHandler);
meshLd.load( new URLRequest("audi/a4_a.3DS"), parseador);
}
public function loaderHandler(e:AssetEvent):void
{
if(e.asset.assetType == AssetType.MESH)
{
car = e.asset as Mesh;
car.position = new Vector3D(100,0,100);
scene.addChild(car);
}
}
public function addLights():void
{
}
public function addListeners()
{
stage.addEventListener(Event.ENTER_FRAME,onEnterFrame);
stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
}
//Listener Handlers
public function onEnterFrame(e:Event):void
{
if (move) {
camCnt.panAngle = 0.3*(stage.mouseX - lastMouseX) + lastPanAngle;
camCnt.tiltAngle = 0.3*(stage.mouseY - lastMouseY) + lastTiltAngle;
}
view.render();
}
private function onMouseDown(event:MouseEvent):void
{
lastPanAngle = camCnt.panAngle;
lastTiltAngle = camCnt.tiltAngle;
lastMouseX = stage.mouseX;
lastMouseY = stage.mouseY;
move = true;
stage.addEventListener(Event.MOUSE_LEAVE, onStageMouseLeave);
}
/**
* Mouse up listener for navigation
*/
private function onMouseUp(event:MouseEvent):void
{
move = false;
stage.removeEventListener(Event.MOUSE_LEAVE, onStageMouseLeave);
}
/**
* Mouse stage leave listener for navigation
*/
private function onStageMouseLeave(event:Event):void
{
move = false;
stage.removeEventListener(Event.MOUSE_LEAVE, onStageMouseLeave);
}
//Fin Listener Handlers
public function addGUI():void
{
}
}
}