Using JS "import" for modular code
Posted: December 6th, 2007, 7:49 am
EDIT: See my reply below to jump straight to the solution
I expect that many of us, myself included, have a few functions that we repeatedly use when scripting. One of the features of Javascript I've most wanted to use is to 'import' other JavaScript files, so that I can keep one updateable library of common functions, and refer to this from other scripts.
Although Im a long time Java coder, AE is my first exposure to JavaScript so I may be doing it wrong, but this command just doesn't seem to work in AE. It accepts the command, and picks up syntax errors if I don't form it right, but it doesn't seem to have any effect. What am I doing wrong?
A.jsx:
B.jsx:
*Awaits a beating with the 'schoolboy error' stick*
I expect that many of us, myself included, have a few functions that we repeatedly use when scripting. One of the features of Javascript I've most wanted to use is to 'import' other JavaScript files, so that I can keep one updateable library of common functions, and refer to this from other scripts.
Although Im a long time Java coder, AE is my first exposure to JavaScript so I may be doing it wrong, but this command just doesn't seem to work in AE. It accepts the command, and picks up syntax errors if I don't form it right, but it doesn't seem to have any effect. What am I doing wrong?
A.jsx:
Code: Select all
import B.jsx
alert(Bfunction());
Code: Select all
function Bfunction()
{
return "success";
}