- Home /
Custom JS class error - function is not a member of the class
I'm trying to make a very basic Momento JS class, but when I call the functions within the class I get the error message storeState and applyState are not members of Momento.
Here's the code for my class
class Memento {
var objectRotation : Quaternion;
var objectPostion : Vector3;
function storeState(player_Object : Transform)
{
objectRotation = player_Object.rotation;
objectPostion = player_Object.position;
}
function applyState(player_Object : Transform)
{
player_Object.rotation = objectRotation;
player_Object.position = objectPostion;
}
}
I then call the functions Momento.storeState(transform object) or Momento.applyState(transform object), but then get the above errors - 'storeState' is not a member of 'Momento' and 'applyState' is not a member of 'Momento'
Any advice is appreciated.
Answer by Mike 3 · Mar 24, 2011 at 06:36 AM
The class is called Memento, but all your errors refer to Momento - could have two similar named classes, and using the wrong one?
Answer by loopyllama · Mar 24, 2011 at 06:44 AM
because your class is called "Memento" and not "Momento", try Memento.storeState