Mailing List AE-List@media-motion.tv ? Message #53661
From: David Torno <torno@sydefxink.com>
Subject: Re: [AE] Extendscript Question - Array length problem
Date: Wed, 23 Apr 2014 10:39:04 -0700
To: After Effects Mail List <AE-List@media-motion.tv>
You should still be able to get the length of the array using length. Object or item based. I would verify that the array keys (.width and .height) are actually populated correctly within the array. I usually make my object arrays a little different and more literal like this. Not that it's right or wrong, just different option.

for(var i=0; i<aryLen; i++){
     myObjectAry.push({'width': ary.width, 'height': ary.height});
}

David Torno
Technical Director
O: 213.739.2290
C: 818.391.6060
--------------------

"The most useless day is that in which we do not laugh"
-Charles Field

On Apr 23, 2014, at 9:29 AM, Phil Bearman <phil@philbearman.co.uk> wrote:

Hi all, 

I'm doing some scripting in AE, and need to iterate through an Array of Objects, so need to find out the number of items in the array in order to set up the loop.

I had expected to be able to get the number of items using myArray.length, but this gives an 'undefined' error in ExtendScript.

The array has been populated with a loop in the following manner:

for (var i=0; i < myWidthValues.length; i++)
{
myArray[i].width=myWidthValues[i];
myArray[i].height=myHeightValues[i];
}

(this isn't the real code, just a simplified example)

And the array is functioning as expected (so for example myArray[2].width gives the result I expect).

Is there a reason that an Array of Objects won't return a 'length' value?

(I know this question would be better suited to a general javascript forum, but I've trawled internet forums to no avail, and thought I'd ask here first in case it's a quirk specific to ExtendScript).

Any help much appreciated!

Phil

--

Phil Bearman

Phil Bearman Creative Media Solutions
Motion Graphics Design

www.PhilBearman.co.uk : Nightclub & Bar ~ Production, Corporate & Events ~ DVD Products 


0161 236 2581 - 9am-5pm, Monday-Friday


 
Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to ListMaster