Accessing functions in external JS imported to resource library?


(Warren Adams-Ockrassa) #1

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) {
externalHello();
}

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


(Lucky) #2

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


(Warren Adams-Ockrassa) #3

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