Accessing functions in external JS imported to resource library?

I’m sure the answer is pretty simple. I’d like to break out some functions I’m going to call, more than once, into an external JS script, imported into my resource library; however, I can’t seem to get them to work.

For instance, as a test, I did this:

function externalHello {
alert(“Hi from the outside world!”);

…and saved it to a file called ‘external.js’, which I then added to my resource library.

However, nothing I do seems to actually call the script. For instance, in my scene load options I select ‘run javascript’, and create a test function called ‘testCall’. Its script looks like this:

function testCall(hypeDocument, element, event) {

…and I get no alert. Obviously I am missing something significant here. So what am I doing wrong?

I think you forgot brackets on this, works for me!
function externalHello() {
alert("Hi from the outside world!");
} (11.0 KB)

1 Like

Le sigh. Indeed, that seems to behave as expected. Thanks!

1 Like