0

I dont know why its giving me the Uncaught ReferenceError: predictMove is not defined. I want to use predictMove() as an auxiliar function. Can you help me please guys?

var Crab = extend(Actor, {
        type : "Crab",
        isStuck : false,
        predictMove : function(auxx, auxy) {
            ............

        },
        animation : function() {
            ......... I call the predictMove() function somewhere in this piece of code......

    })
Miguel Morujão
  • 1,131
  • 1
  • 14
  • 39
  • 3
    We don't have enough code but you probably don't have the right context (`this`). – Denys Séguret May 29 '14 at 15:57
  • 2
    How are you calling `predictMove()`? Are you doing `this.predictMove()`? How are you calling `animation()`? Are you sure `this` is what you think it is? Are you trying to do `this.predictMove()` inside of a callback? – gen_Eric May 29 '14 at 15:58
  • this link may help you get a better understanding of scope and how you could set up your object. http://stackoverflow.com/a/13074081/1257652 – Brett Weber May 29 '14 at 16:18

1 Answers1

0

The function invokations that are giving undefined error:

this.functionName(...); // Important: Add the **this**

FYI: You have a scoping issue.

Mathew Kurian
  • 5,949
  • 5
  • 46
  • 73