A simple way to dynamically evaluate multiple JSX files in the Scripting context of Photoshop within HTML Panels. Back in the Flash world, I used to dynamically include external JSX files via:
Being $.fileName the current JSX file within the above line is written and the File.path call meaning the actual path. Alas, this doesn’t seem to work anymore when HTML panels are involved - the File($.fileName).path once resulted to me, don’t ask me why, as “33” - which is not a bad approximation to the answer to the Ultimate Question of Life, the Universe, and Everything after all ;-) Anyway, what I personally use now is the following function (in the main.js file):
The key here is the above highlighted line, which is the JS equivalent of the JSX line I’ve been using. To load a JSX - which must belong to the root/jsx folder since it’s hardwired in the function, you would write:
Borrowing code from the Extension Builder 3 boilerplate you can get fancier. The first chunk goes in the main JSX, i.e. the one listed in the manifest.xml, enclosed in the ScriptPath tag:
This instead is what goes in the main.js
loadJSX() (for instance called in the init() function) will evaluate all the JSX files in the predefined folder.
Bonus - System Paths
You may be interested in these ones too (from CSInterface-4.0.0.js)
The Photoshop HTML Panels Development Course
If you’re reading here, you might be interested in my Photoshop Panels development – so let me inform you that I’ve authored a full course:
300 pages PDF
3 hours of HD screencasts
28 custom Panels with commented code
Check it out! Please help me spread the news – I’ll be able to keep producing more exclusive content on this blog. Thank you!