FORUMS: list search recent posts

getting "ReferenceError: Object is invalid" while resetting a listBox

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Dror Lazar
getting "ReferenceError: Object is invalid" while resetting a listBox
on Jun 19, 2016 at 5:24:37 am

Hi
i'm trying to create a refresh button for a list (that shows the render Q better for my needs). it works fine, i'm removing all the list items and then re-entering them. for some reason when i click the same refresh button for the 6th/7th time i'm getting:

ReferenceError: Object is invalid

(it seems to be related to line 66 in the code - " curItem = folderPathListbox.add ('item', renderItem.toString()); // Column 1")
any help?
i'm lost here...
attached are the JSX and a sample project i use to test it:
JSX - http://adobe.ly/1tC5jcj
AEP - http://adobe.ly/1UfMfXF

thanks
D

try{

function createUserInterface (thisObj,userInterfaceString,scriptName){
var pal = (thisObj instanceof Panel) ? thisObj : new Window("palette", scriptName,
undefined,{resizeable: true});
if (pal == null) return pal;

var UI=pal.add(userInterfaceString);

pal.layout.layout(true);
pal.layout.resize();
pal.onResizing = pal.onResize = function () {
this.layout.resize();
}
if ((pal != null) && (pal instanceof Window)) {
pal.show();
}
return UI;
};






{var res ="group {orientation:'column',\
alignment:['fill','fill'],\
alignChildren:['fill','top'],\
headerText:StaticText {text:'Render Q lister', alignment:'center'},\
buttonGroup: Group{\
alignment:['center','top']\
refButton: Button{text:'Refresh'}\
dupButton: Button{text:'Duplicate Selected'}\
selButton: Button{text:'Select in renderQueue'}\
expButton: Button{text:'Export to File'}\
}\
folderPathListbox:ListBox{\
alignment:['fill','fill'],\
properties:{\
multiline:true,\
multiselect:true,\
numberOfColumns:5,\
showHeaders:true,\
columnTitles: ['Render #','Date','Time', 'Comp Name', 'Render Path']\
}\
},\
}";

}
function listRQ (rqList){
try{
var folderPathListbox = rqList;
var proj = app.project;
var totalRenderQ = proj.renderQueue.numItems;
for(var i= 1; i&lt;=totalRenderQ; i++){
var totalOM= proj.renderQueue.item(i).numOutputModules;
for (var om= 1; om&lt;=totalOM; om++){
var dateList, timeList, curItem, renderItem;
renderItem = "Render #" + i + " - " + om ;
if (proj.renderQueue.item(i).startTime != null){
var min = proj.renderQueue.item(i).startTime.getMinutes() &lt;10 ? "0"+ proj.renderQueue.item(i).startTime.getMinutes() : proj.renderQueue.item(i).startTime.getMinutes();
var year = proj.renderQueue.item(i).startTime.getFullYear().toString().substr (-2,2);
timeList = (proj.renderQueue.item(i).startTime.getHours()-1)+":" + min;
dateList =proj.renderQueue.item(i).startTime.getDate()+"/"+(proj.renderQueue.item(i).startTime.getMonth()+1)+"/"+year ;
}else{
dateList = "not rendered";
timeList = " ";
}
curItem = folderPathListbox.add ('item', renderItem.toString()); // Column 1
curItem.subItems[0].text = dateList.toString(); // Column 2
curItem.subItems[1].text = timeList.toString(); // Column 3
curItem.subItems[2].text = proj.renderQueue.item(i).comp.name; // Column 4
curItem.subItems[3].text = proj.renderQueue.item(i).outputModule(om).file.toString().replace(new RegExp(",","g"), "\r").replace(new RegExp("%20","g"), " ").replace(new RegExp("%5B","g"), "[").replace(new RegExp("%5D","g"), "]"); // Column 5
}
}
}catch(err){alert(err)}
return folderPathListbox;
}


var UI = createUserInterface(this,res,"Better RQ");
var myList = UI.folderPathListbox;
var lsRq = listRQ(myList);


{ // buttons action
UI.buttonGroup.refButton.onClick = function () {

lsRq.removeAll();
lsRq = listRQ(myList);

}
UI.buttonGroup.dupButton.onClick = function () {
alert ("Dup");
}
UI.buttonGroup.selButton.onClick = function () {
alert ("Sel");
}
UI.buttonGroup.expButton.onClick = function () {
alert ("Exp");
}
}




}
catch(err){
alert ("Error at line # " + err.line.toString() + "\r" + err.toString());
}




Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]