# TypeError, cant figure it out

**URL:** https://forum.kirupa.com/t/typeerror-cant-figure-it-out/315587
**Category:** flash
**Created:** [October 29, 2010, 1:54pm UTC](https://forum.kirupa.com/t/typeerror-cant-figure-it-out/315587 "2010-10-29T13:54:54Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![timba](https://avatars.discourse-cdn.com/v4/letter/t/a88e57/32.png) [@timba](https://forum.kirupa.com/u/timba)
#### Post date: [October 29, 2010, 1:54pm UTC](https://forum.kirupa.com/t/typeerror-cant-figure-it-out/315587/1 "2010-10-29T13:54:54Z")

</div>

TypeError: Error #1009: Cannot access a property or method of a null object reference.

I know everyone hates these errors, but i cant seem to get rid of it.  
I’m working on a project for school that includes pathfinding, the pathfinding part is all done but now for the tweening to make the character (Doctor) walk the path. My solution to this came up like this (its probably not perfect yet but hey, I’m still in school)

the function that starts filling the array with movement tweens (I’m not quite sure if this will work, maybe thats what’s causing the error)

```auto
        function Move(event:MouseEvent):void {
                    path=$grid.findPath("n1","n6");
                    
                    for (var i:int = 0; i <path._path.length; i++) {
                    var nextNode=$grid.getNodeById(path._path*);
                    trace(nextNode);
                    var tx=nextNode.x;
                    var ty=nextNode.y;
                    trace(tx);
                    var dx:Number=tx-Doctor.x;
                    var dy:Number=ty-Doctor.y;
                    var dis:Number=Math.sqrt(dx*dx+dy*dy);
                    //how long will it take
                    var time:Number=dis/speed;
                    //if (dis!=0) {
                        tweenArrayX*=new Tween(Doctor,"x",None.easeNone,Doctor.x,tx,time,false);
                        tweenArrayY*=new Tween(Doctor,"y",None.easeNone,Doctor.y,ty,time,false);
                    //}
                    if (i==path._path.length) {
                        startMoving=true;
                    }
                }
        }

```

the Update function

```auto
        function Update(event:Event):void {
                
                if (startMoving== true){
                if (!moving) {
                    
                    for (var u:int = 0; u <tweenArrayX.length; u++) {
                        tweenerX=tweenArrayX[u];
                        tweenerY=tweenArrayY[u];
                        tweenerX.addEventListener(TweenEvent.MOTION_FINISH, MoveComplete);
                        moving=true;
                        
                        if (u == tweenArrayX.length)
                        {
                            startMoving=false;
                        }
                    }
                }
                }
            
        }

```

The error is in the

```auto
tweenArrayX*=new Tween(Doctor,"x",None.easeNone,Doctor.x,tx,time,false);
                        tweenArrayY*=new Tween(Doctor,"y",None.easeNone,Doctor.y,ty,time,false);

```

part

I’d be really glad if someone can help me out on this! or even help me improve it!

\*\*  
sorry it’s a bit messy, but i haven’t gotten round to cleaning up yet.  
\*\*
