function defined in another file

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
pirelouit
Posts: 18
Joined: January 16th, 2006, 12:08 pm

Maybe it is a stupid question, but how do you make a call to a function defined in another file? I imagine you must specify a relative path, but I couldn't find anything about it in the adobe documentation.

Thanks
User avatar
redefinery
Posts: 112
Joined: April 1st, 2005, 8:16 pm
Location: CA
Contact:

In AE 6.5 or later, you'll need to open the file, eval() its contents, then close the file, as in:

Code: Select all

	var myCodeFile = new File("codeFile.jsx");
	myCodeFile.open("r");	
	eval( myCodeFile.read() );
	myCodeFile.close();
See the render_and_email.jsx script for examples.

In AE 7, you can use the new #include directive, as in:

Code: Select all

	#include "codeFile.jsx"
Jeff
pirelouit
Posts: 18
Joined: January 16th, 2006, 12:08 pm

Thank you, I realized now I was simply not looking in the right place in the documentation. I appreciate the quick feedback.
Tigerfog
Posts: 8
Joined: May 25th, 2007, 8:38 am
Location: Canada
Contact:

Hi.
I have tried to use the codes that you have given me.

However, when I run my script, it says "Expected: (" at the line where "#include" is.
Then, I tried again with parentheses around the URI path of my jsx file. This time, the message I get was that the file or folder does not exist, even though I correctly input the absolute path of my script.

Is there another way to script a reference to an external file?
My TMNT webcomic/manga online.
http://www.obscurezodiac.com
Tigerfog
Posts: 8
Joined: May 25th, 2007, 8:38 am
Location: Canada
Contact:

Sir pirelouit found the solution for me!
My script with the "#include" code worked on his MAC, but not my poor, poor PC. :P
Here is what he gave me and this time, my script ran perfectly on my PC:

// @include "(path)";
My TMNT webcomic/manga online.
http://www.obscurezodiac.com
Post Reply