Imports aren't inherited with Actionscript. If you need a class definition (eg. Vertex) in a class, you need the imports, no matter if it has been imported in the base-class or not.
On Jun 17, 2:39 pm, rowild <[email protected]> wrote: > OK, I tried your suggestion and it works now, as soon as the Vertex > class is imported. Thank you for your hint! > Can you clarify another problem for me, please? > The Vertex class was actually importet in the Away3D_BaseClass2, which > gets extended (import away3d.core.base.*;) But if it is imported only > in the BaseClass, I get the error > > /.../Away3D_drawLines.as, Line 31 1180: Call to a possibly undefined > method Vertex. > > As soon as I import the class in the Away3D_drawLines class, > everything is ok. --- Did I miss sth on importing classes and the > extends prinzipile of Flash OOP??? > > Infos on the book: > The book is actually by Rob Bateman & Richard Olsson, both core > developers of Away3D. The book itself is Copyright 2010, not too long > ago ( I think April) > > Thanks again! > > On 17 Jun., 13:16, banal <[email protected]> wrote: > > > I'm sorry, my answer was not very specific on what was the cause of > > the error. > > The error is caused, because you're using Number3D Objects for your > > calculations, but the LineSegment class expects it's start and end > > properties to be of type "Vertex". > > Since Number3D is not a Vertex, you get a compiler error. > > As seen in my previous post, you should be able to solve the issue by > > creating new Vertex objects using the coordinates of the Number3D > > Objects. > > > On Jun 17, 1:08 pm, banal <[email protected]> wrote: > > > > It's an error in your Away3D_drawLines class which uses Number3D > > > instead of the Vertex class. > > > I think this is a change that was introduced after the writing of the > > > Book? > > > > You could easily fix that by writing: > > > seg.start = new Vertex(p1.x, p1.y, p1.z); > > > seg.end = new Vertex(p2.x, p2.y, p2.z); > > > > On Jun 17, 12:43 pm, rowild <[email protected]> wrote: > > > > > 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!
