Please try to use as few global variables as possible. With many of them, it’s easy to just see where they have gone sideways as value. Just declare values locally and pass them as function argumentts. Also, try to put var in front of the for variable. I will try to reproduce your code as i would make it.
var selection = app.project.selection;
function findSel(selection){
var selAry = []
for (var i=0;i<selection.length;i++){
var currentItem= selection[i];
if(currentItem.typeName != "Folder"){
selAry.push(currentItem);
}else{
selAry.push(currentItem);
folderSearch(currentItem);
}
}
function folderSearch(myFolder){
for (var i=1; i<=myFolder.items.length; i++){
var curFolderItem = myFolder.items[i];
if(curFolderItem.typeName != "Folder"){
selAry.push(curFolderItem);
}else{
selAry.push(curFolderItem);
folderSearch(curFolderItem);
}
}
}
return selAry;
}
var mySelectedItems = findSel (selection);
alert(mySelectedItems)
The mySelectedItems variable is the array that contains the selected items. Last alert is just for checking.
Andrei
My Envato portfolio.