Call function form external and already loaded js
Neogene

Hi,

 

i'm studying wade flow test game

 

inside the move handler i try to call a function which is inside another js file loaded before the wade game. 

 

main.html

- load main.js (contains a function called FinishedGame());

- load wade.js

- load flow.js

 

Inside flow.js

this.onMouseMove = function(eventData) {

    //code

   FinishedGame(); //error

}

 

The error is ReferenceError: Can't find variable FinishedGame

 

There is a way to call external methods?

 

Thank you in advance.

 

All 2 Comments
Gio

Hi

 

In general there is nothing special that you have to do to call external functions. What you are doing looks like it should work, but it may be that FinishedGame() has not been declared in the global scope?

 

It's difficult to tell without seeing what main.js does, could you attach your project as a zip file or send me an email (gio at clockworkchilli dot com) and I'll have a look

Neogene

The problem was due to the fact that the function called was inside another callback, i found a solution passing the external function as parameter into the appData parameter of the caller. Thank you.

Post a reply
Add Attachment
Submit Reply
Login to Reply