Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After Effects / ExtendScript: Using libraries and importing .jsx files?

I am new to After Effects scripting but have much experience with JavaScript in the browser.

  1. How do I import .jsx files?
  2. Can I use js libraries such as underscore.js etc?
  3. What are some good resources for AE scripting? (Ideally infographics projects)
like image 486
dani Avatar asked Feb 03 '13 20:02

dani


1 Answers

  1. To include a .jsx next to your script

use:

#include "includeme.jsx"

EDIT 2:

You can also include files using the following syntax:

//@include "includeme.jsx"

Which (IMHO) is the better way. It wont break a linter and is more javascript-ish.

  1. You can use plain old javascript (ES3 Syntax). If the libraries you include use some browser specific js (like console.log()) you will get an error

  2. Best resource is the AECS6 scripting guide. There are also lots of open source scripts on http://aescripts.com that you can examine

EDIT 1: You can also include a file like this.

var path = ((File($.fileName)).path); // this is the path of the script
// now build a path to another js file
// e.g. json lib https://github.com/douglascrockford/JSON-js
var libfile = File(path +'/_libs/json2.js');
if(libfile.exists){
  $.evalFile(libfile);
}
like image 194
fabianmoronzirfas Avatar answered Oct 20 '22 09:10

fabianmoronzirfas