Recursive checking pre-comps for missing footage
Posted: October 12th, 2006, 8:25 am
As i am getting more and more comfortable with scripting i sometime hit some walls that i have a hard time getting around.
I am trying to write a simple function that check for missing footage in a particular comp. It's pretty straight forward as long as the missing item is in that parent comp. The way i am accomplishing this is by doing a for loop in the project window using footageMissing and then using usedIn to check whether that missing footage is in my comp.
The problem is if the footage is in a pre-comp that is then in my parent comp. I can write another for loop to go in 1 more comp up, but pre-comps could be infinately deep so i am stuck figuring out how to keep recursively checking until i find the top-most comp. My guess is that this can be done more efficiently than the way i am approaching it..
any help will be greatly appreciated..
to clarify what i am looking to do: I want to check whether a comp has any missing footage in it. This missing footage could be located within a pre-comp that is in this comp.. That is what i am having trouble with.
this is what i have so far:
I am trying to write a simple function that check for missing footage in a particular comp. It's pretty straight forward as long as the missing item is in that parent comp. The way i am accomplishing this is by doing a for loop in the project window using footageMissing and then using usedIn to check whether that missing footage is in my comp.
The problem is if the footage is in a pre-comp that is then in my parent comp. I can write another for loop to go in 1 more comp up, but pre-comps could be infinately deep so i am stuck figuring out how to keep recursively checking until i find the top-most comp. My guess is that this can be done more efficiently than the way i am approaching it..
any help will be greatly appreciated..
to clarify what i am looking to do: I want to check whether a comp has any missing footage in it. This missing footage could be located within a pre-comp that is in this comp.. That is what i am having trouble with.
this is what i have so far:
Code: Select all
var projItems = app.project.items;
var missingItems = 0;
var missingFootageArray = new Array();
for (j=1; j < projItems.length; j++){
if (projItems[j].footageMissing == true) {
missingItems = missingItems + 1;
if (projItems[j].usedIn.length > 0){
var compsUsedIn = projItems[j].usedIn;
if (compsUsedIn.length > 0) {
var compsUsedInNames = new Array();
for (k=0; k < compsUsedIn.length; k++){
compsUsedInNames[k] = compsUsedIn[k].name;
}
}
missingFootageArray[missingFootageArray.length] = String(projItems[j].name) + " Used In: " + String(compsUsedInNames) + "\r";
}
}
}
alert(missingFootageArray);