Hi,
I bought the book "The Essential Guide to 3D in Flash", which is
totally about Away3D. I am in chapter 4, where this code is posted
(compared to the book, I changed the names of the classes):
// Base Class
package
{
import away3d.core.base.*;
import away3d.cameras.*;
import away3d.containers.*;
import flash.display.*;
import flash.events.*;
public class Away3D_BaseClass2 extends Sprite
{
protected var _camera:HoverCamera3D;
protected var _view:View3D;
public function Away3D_BaseClass2()
{
super();
_createView();
_createScene();
}
protected function _createView():void
{
_camera = new HoverCamera3D();
_camera.distance = 1000;
_camera.tiltAngle = 10;
_camera.panAngle = 180;
_view = new View3D();
_view.x = 400;
_view.y = 300;
_view.camera = _camera;
addChild(_view);
addEventListener(Event.ENTER_FRAME, _onEnterFrame);
}
protected function _createScene():void
{
// To be overridden
}
protected function _onEnterFrame(ev : Event):void
{
_camera.panAngle += (stage.mouseX - stage.stageWidth/2)
/ 100;
_camera.hover();
//_camera.steps = 2;
_view.render();
}
}
}
// Extending Class (in new File of course)
package
{
import away3d.core.math.*;
import away3d.primitives.LineSegment;
[SWF(width="800",height="600")]
public class Away3D_drawLines extends Away3D_BaseClass2
{
public function Away3D_drawLines():void
{
super();
}
override protected function _createScene():void
{
var i:int, p1:Number3D, p2:Number3D, seg:LineSegment;
p1 = new Number3D();
p2 = new Number3D();
for (i=0; i < 5; i++)
{
p2.x = (Math.random() - 0.5) *200;
p2.y = (Math.random() - 0.5) *200;
p2.z = (Math.random() - 0.5) *200;
p2.add(p2, p1);
seg = new LineSegment();
seg.start = p1;
seg.end = p2;
_view.scene.addChild(seg);
p1.clone(p2);
}
}
}
}
and this error message shows up in my Flash CS5:
/...h/Away3D_drawLines.as, Line 31 1067: Implicit coercion of a value
of type away3d.core.math:Number3D to an unrelated type
away3d.core.base:Vertex.
I cannot solve this problem, and there is no Errata page at friendsof
ed.com.
Can anybody give me a hint what's wrong here?
Thanks!