I can also make a button in the palette.
I can't seem to make the button to execute a script though..
The script is already in the scripts folder, I have the directory set and pointing to the script I would like to execute.. however, when I press the button, it just stares at me.
When I open After Effects and the palette loads, there are no errors.
I made the script name in the code vague, but it should still work the same.. if there's a script called script1.jsx in the scripts folder.
Is it a syntax issue or an issue of scope as to why this is not triggering it?
Code: Select all
{
function BuildAndShowUI(thisObj)
{
// Create and show a floating palette.
var my_palette = (thisObj instanceof Panel) ? thisObj : new Window("palette", "", undefined, {resizeable:true});
if (my_palette != null)
{
var res =
"group { \
orientation:'column', alignment:['fill','top'], alignChildren:['left','top'], spacing:5, margins:[0,0,0,0], \
button1: Button { text:'script1', maximumSize:[100,40], alignment:['left','top'] }, \
optsRow: Group { \
orientation:'row',\
}, \
}";
my_palette.margins = [10,10,10,10];
my_palette.grp = my_palette.add(res);
my_palette.layout.layout(true);
my_palette.layout.resize();
my_palette.onResizing = my_palette.onResize = function () {this.layout.resize();}
my_palette.grp.button1.onClick = script1fn;
}
return my_palette;
}
function script1fn()
{
var getScript1 = new File( "C:\\Program Files (x86)\\Adobe\\Adobe After Effects CS4\\Support Files\\Scripts\\script1.jsx");
getScript1.open( "r" );
eval( getScript1.read() );
getScript1.close();
}
// The Main Script
var my_palette = BuildAndShowUI(this);
if (my_palette != null) {
if (my_palette instanceof Window) {
my_palette.center();
my_palette.show();
} else {
my_palette.layout.layout(true);
}
} else {
alert("Could not open the user interface.", scriptName);
}
}