-3

How do I store ExtendScript objects in associative array?

var assArray = {};

for (i=1; i<=app.project.items.length; i++) {
    //alert(app.project.item(i).name); one of them is "_vegs"
    assArray[app.project.item(i).name] = app.project.item(i);
}

alert(assArray["_vegs"].name);

This code returns error at the second alert line.

Unable to execute script at line 9. undefined is not an object.

What am I missing here?

sanjihan
  • 5,592
  • 11
  • 54
  • 119

1 Answers1

0
var assArray = {};

for (i=1; i<=app.project.items.length; i++) {
    //alert(app.project.item(i).name); one of them is "_vegs"
    assArray[app.project.item[i].name] = app.project.item[i];
}

alert(assArray["_vegs"].name);

I think the problem is in (i) hopefully [i] will work

Ankit vadariya
  • 1,253
  • 13
  • 14
  • Nah, item() is a function in extendscript. It looks like they don't allow storing objects in arrays. – sanjihan Jan 27 '17 at 13:49