it works but...
try
inc += 0.01;

What is happening is: it goes so fast, just 10 updates per sec that it
reaches the end and go back to zero.

I've changed here and there your code...

note that in 2.6 you do not longer need to have an extra point to
define a line for a Path (was a "controled" bug until all other
classes were compatible)
if you use official tag release, then keep your code.

Fabrice

package nl {
        import away3d.animators.PathAnimator;
        import away3d.animators.data.Path;
        import away3d.cameras.Camera3D;
        import away3d.containers.View3D;
        import away3d.core.math.Number3D;
        import away3d.extrusions.PathExtrude;
        import away3d.primitives.Cube;
        import flash.display.Sprite;
        import flash.events.Event;

        public class PathAnimatorTest extends Sprite
        {
                private var view:View3D;
                private var cam:Camera3D;
                private var cube:Cube;
                private var animator:PathAnimator;
                private var _path:Path;
                private var ext:PathExtrude;
                private var inc:Number = 0;

                public function PathAnimatorTest()
                {
                       addEventListener(Event.ADDED_TO_STAGE, init);
                }
                private function init(e:Event):void
                {
                                                view = new View3D();
                                                view.x = stage.stageWidth *.5;
                                                view.y = stage.stageHeight *.5;
                                                view.camera.z = -2000;
                                                addChild(view);
                        view.camera.y = 2000;
                        view.camera.lookAt(new Number3D(0,0,0));

                                                cube = new Cube();
                        cube.x = 100;
                        view.scene.addChild(cube);

                        _path = new Path([new Number3D(0,0,0), new
Number3D(0,0,2500),new Number3D(0,0,5000)]);
                                                var points:Array = [new 
Number3D(100,0,0), new Number3D
(-100,0,0)];
                        ext = new PathExtrude(_path,points, null,
null, {});
                        view.scene.addChild(ext);

                        this.animator = new PathAnimator(_path, cube,
{lookat:false, aligntopath:false});
                        this.addEventListener(Event.ENTER_FRAME,
enterFrame);
                }
                private function enterFrame(e:Event):void
                {

                                                try{
                                                        inc = (inc + 0.1 > 1)? 
0 : inc+0.1;
                                                        
this.animator.update(inc);
                                                        view.render();
                                cube.rotationX++;
                                                        
view.camera.lookAt(this.animator.position);
                                                } catch (e:Error){
                                                        trace("error...");
                                                }
                }
        }
}



On Jan 20, 9:37 am, Fabrice <[email protected]> wrote:
> oh haven't seen that mail...
> I'll have a look...
>
> Fabrice
> On Jan 20, 2009, at 6:33 AM, Patrick wrote:
>
>
>
> > package {
> >    import away3d.animators.PathAnimator;
> >    import away3d.animators.data.Path;
> >    import away3d.cameras.Camera3D;
> >    import away3d.containers.View3D;
> >    import away3d.core.math.Number3D;
> >    import away3d.extrusions.PathExtrude;
> >    import away3d.primitives.Cube;
>
> >    import flash.display.Sprite;
> >    import flash.events.Event;
>
> >    public class PathAnimatorTest extends Sprite
> >    {
> >            private var view:View3D;
> >            private var cam:Camera3D;
> >            private var cube:Cube;
> >            private var animator:PathAnimator;
> >            private var _path:Path
> >            private var ext:PathExtrude;
>
> >            private var inc:Number = 0;
>
> >            public function PathAnimatorTest()
> >            {
> >                    init();
> >            }
>
> >            private function init():void
> >            {
> >                    cam = new Camera3D;
> >                    cam.z = -2000;
> >                    cam.moveUp(2000);
> >                    cam.lookAt(new Number3D(0,0,700));
>
> >                    cube = new Cube();
> >                    cube.x = 100;
>
> >                    view = new View3D();
> >                    view.x = 200;
> >                    view.y = 200;
> >                    view.camera = cam;
> >                    this.view.scene.addChild(cube);
> >                    this.addChild(view);
>
> >                    _path = new Path([new Number3D(0,0,0), new 
> > Number3D(0,0,0),new
> > Number3D(0,0,0),null,new Number3D(0,0,0),new Number3D(0,0,5000)]);
>
> >                    ext = new PathExtrude(_path,[new Number3D(100,0,0),new 
> > Number3D
> > (-100,0,0)],null,null,null);
> >                    this.view.scene.addChild(ext);
>
> >                    this.animator = new PathAnimator(this._path, this.cube,
> > {lookat:false, aligntopath:false});
>
> >                    this.addEventListener(Event.ENTER_FRAME, enterFrame);
> >            }
>
> >            private function enterFrame(e:Event):void
> >            {
> >                    //inc += 0.1;
> >                    this.animator.update(0);
> >                    view.render();
> >                    cube.rotationX++;
>
> >            }
> >    }
> > }
>
> > On Jan 20, 5:19 am, Patrick <[email protected]> wrote:
> >> Hi All,
>
> >> I am having a problem to animate an object along a path. I followed
> >> Fabrice's tutorial.
>
> >> When I call the update method in the render loop and pass a value 0
> >> the object, in my case a cube,  is positioned at the beginning of the
> >> path. If I change the value passed to anything other than 0 but still
> >> below 1, the code breaks.
>
> >> Why is         pathAnimator.update(0);    working,
>
> >> but               pathAnimator.update(0.5);    not?
>
> >> Any answers will be appreciated. :)
>
> >> Thanks, Patrick

Reply via email to