I have a strange problem that's driving me crazy. It might very well be that I'm misunderstanding the syntax, but I can't seem to find a solution. Anyway, the problem is the following:
I have a script with a button and a dropdown list. When I press the button the script will alert the active composition and it will alert the current selection of the dropdown list. The script can be run both as a panel and as a palette.
I then have another script that has only one button. If I press it it will alert a string. This also works. However, if I run the first script, then run the second script, and then run the first script again, I can no longer call the value of the dropdown list (myPalette.grp.one.dropdown.selection.toString()). It seems like running another script (I've tested with others and same result) breaks the first script and it has to be re-launched.
This is causing problems and I would very much appreciate if anyone could help me with this. I will attach the code for the two test scripts below.
Script 1:
Code: Select all
var dropDown = new Array ("1", "2", "3", "4")
// Build UI
var myPalette = buildUI(this);
if(myPalette != null && myPalette instanceof Window) {
myPalette.show();
}
function buildUI (thisObject) {
if(thisObject instanceof Panel) {
var myPalette = thisObject;
}else{
var myPalette = new Window ("palette", "test", undefined, {resizeable:true});
}
if (myPalette != null) {
var res =
"Group { \
orientation: 'column', \
alignment: ['fill', 'fill'], \
alignChildren: ['left', 'top'], \
minimumSize: [125, 26],\
one: Group { \
orientation: 'row', \
dropdown: DropDownList {size: ['100', '25']}, \
button01: Button {text:'test', size: ['85', '25']}, \
} \
}";
myPalette.grp = myPalette.add(res);
myPalette.layout.layout(true);
myPalette.layout.resize()
myPalette.resizing = myPalette.onResize = function () {this.layout.resize()};
// Populate view lut dropdown list.
for(i=0; i<dropDown.length; i++) {
myPalette.grp.one.dropdown.add('item',dropDown[i]);
}
// Set default dropdown selection.
myPalette.grp.one.dropdown.selection = myPalette.grp.one.dropdown.items[0];
myPalette.grp.one.button01.onClick = function () {
button01 (myPalette);
}
}//if(myPalette != null) {
return myPalette;
} //buildUI
function button01 (palObject) {
// Check that a single comp is selected or active
if (app.project.activeItem == null){
alert("Select a composition.");
return;
}
var myComp = app.project.activeItem.name;
alert("The active composition is: " + myComp);
var mySelection = myPalette.grp.one.dropdown.selection.toString();
alert("The current selection is: " + mySelection);
}
Code: Select all
// Build UI
var myPalette = buildUI(this);
if(myPalette != null && myPalette instanceof Window) {
myPalette.show();
}
function buildUI (thisObject) {
if(thisObject instanceof Panel) {
var myPalette = thisObject;
}else{
var myPalette = new Window ("palette", "test", undefined, {resizeable:true});
}
if (myPalette != null) {
var res =
"Group { \
orientation: 'column', \
alignment: ['fill', 'fill'], \
alignChildren: ['left', 'top'], \
minimumSize: [125, 26],\
one: Group { \
orientation: 'row', \
temp: Button {text: 'temp', size: ['85', '25']}, \
} \
}";
myPalette.grp = myPalette.add(res);
myPalette.layout.layout(true);
myPalette.layout.resize()
myPalette.resizing = myPalette.onResize = function () {this.layout.resize()};
myPalette.grp.one.temp.onClick = function () {
temp (myPalette);
}
}//if(myPalette != null) {
return myPalette;
} //buildUI
function temp (palObject) {
alert("tester");
}