Hello, maybe i’m doing something wrong, i try to call a function inside a script (function is in the same script) and i use this.functionName() but it say that is not a function…i think i’m going senile…where i do wrong?
post the script, that must have be some sintax error
1 Like
How on earth could anyone know what’s wrong without looking at the code??
Lol,
a sintax! it we start taxing people for their sins where will it all end ?
1 Like
syntax*, sorry for my english
sorry, since that line didn’t seem to work but calling it from another script it does work i just added an if statement and solved my problem …deepest apologizes
ok seems my solution was not doable so i post here the function and how i call it
closeShop: function(){
this.isOpen = false;
this.clear();
this.shopDiv.classList.remove(this.shopOpenClass);
},
called by this.closeShop()
ps this is the project https://playcanvas.com/editor/scene/396696 and the script is Shop.js
This appears to be another misunderstanding of the ‘this’ keyword.
You call closeShop
like this:
r.click(function(){
this.closeShop();
});
It should either be:
r.click(function(){
this.closeShop();
}.bind(this));
Or:
var self = this;
r.click(function(){
self.closeShop();
});
The latter is a bit more optimal.