Script Executed after Error
Posted: July 29th, 2011, 3:41 pm
Hi everyone!
I've been learning to script for the last two weeks or so and man, is it addictive :)
Though, something is unclear. The code below returns 'undefined is not an object' on the second line of the loop. The Intro to Scripting PDF tells me this error is only returned when the hierarchy isn't completly defined. But the hierarchy is well defined in this case. Or am I missing something? The weird thing is that the script is executed anyway after I cancel from ExtendScript Toolkit.
As far as I know the square brackets are right, since selectedLayers returns an array. And if I use a break on the third line of the loop, there is no error, but the loop obviously breaks after the first layer.
Could anyone enlighten me?
I've been learning to script for the last two weeks or so and man, is it addictive :)
Though, something is unclear. The code below returns 'undefined is not an object' on the second line of the loop. The Intro to Scripting PDF tells me this error is only returned when the hierarchy isn't completly defined. But the hierarchy is well defined in this case. Or am I missing something? The weird thing is that the script is executed anyway after I cancel from ExtendScript Toolkit.
As far as I know the square brackets are right, since selectedLayers returns an array. And if I use a break on the third line of the loop, there is no error, but the loop obviously breaks after the first layer.
Could anyone enlighten me?
Code: Select all
var myComp = app.project.activeItem;
var myLayers = myComp.selectedLayers;
var myDuration = myComp.workAreaDuration;
for(var i = 0; i <= myLayers.length; i++){
//myLayers[i].inPoint = myComp.workAreaStart;
myLayers[i].outPoint = myDuration;//hm, returns 'undefined is not an object', but performs action after cancel.
}