Return-Path: Received: from atl4mhob10.myregisteredsite.com ([209.17.115.48] verified) by media-motion.tv (CommuniGate Pro SMTP 4.2.10) with ESMTP id 5451386 for AE-List@media-motion.tv; Wed, 23 Apr 2014 19:39:06 +0200 Received: from mailpod.hostingplatform.com ([10.30.71.210]) by atl4mhob10.myregisteredsite.com (8.14.4/8.14.4) with ESMTP id s3NHd4Cs023894 for ; Wed, 23 Apr 2014 13:39:04 -0400 Received: (qmail 17142 invoked by uid 0); 23 Apr 2014 17:39:04 -0000 X-TCPREMOTEIP: 108.184.252.87 X-Authenticated-UID: torno@sydefxink.com Received: from unknown (HELO ?192.168.0.8?) (torno@sydefxink.com@108.184.252.87) by 0 with ESMTPA; 23 Apr 2014 17:39:04 -0000 From: David Torno Content-Type: multipart/alternative; boundary=Apple-Mail-CF4C1F38-74BF-4E30-A72E-87F6DF2BBD09 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (1.0) Subject: Re: [AE] Extendscript Question - Array length problem Message-Id: <784C859E-BB77-4F7D-9C1A-30D782394732@sydefxink.com> Date: Wed, 23 Apr 2014 10:39:04 -0700 References: In-Reply-To: To: After Effects Mail List X-Mailer: iPhone Mail (11B651) --Apple-Mail-CF4C1F38-74BF-4E30-A72E-87F6DF2BBD09 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable 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 a= ctually populated correctly within the array. I usually make my object array= s a little different and more literal like this. Not that it's right or wron= g, just different option. for(var i=3D0; i On Apr 23, 2014, at 9:29 AM, Phil Bearman wrote: >=20 > Hi all,=20 >=20 > I'm doing some scripting in AE, and need to iterate through an Array of Ob= jects, so need to find out the number of items in the array in order to set u= p the loop. >=20 > I had expected to be able to get the number of items using myArray.length,= but this gives an 'undefined' error in ExtendScript. >=20 > The array has been populated with a loop in the following manner: >=20 > for (var i=3D0; i < myWidthValues.length; i++) > { > myArray[i].width=3DmyWidthValues[i]; > myArray[i].height=3DmyHeightValues[i]; > } >=20 > (this isn't the real code, just a simplified example) >=20 > And the array is functioning as expected (so for example myArray[2].width g= ives the result I expect). >=20 > Is there a reason that an Array of Objects won't return a 'length' value? >=20 > (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 fir= st in case it's a quirk specific to ExtendScript). >=20 > Any help much appreciated! >=20 > Phil >=20 > --=20 > Phil Bearman >=20 > Phil Bearman Creative Media Solutions=20 > Motion Graphics Design >=20 > www.PhilBearman.co.uk : Nightclub & Bar ~ Production, Corporate & Events ~= DVD Products=20 >=20 > 0161 236 2581 - 9am-5pm, Monday-Friday >=20 >=20 --Apple-Mail-CF4C1F38-74BF-4E30-A72E-87F6DF2BBD09 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
You should still be able to get the le= ngth of the array using length. Object or item based. I would verify that th= e array keys (.width and .height) are actually populated correctly within th= e 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.
<= br>
for(var i=3D0; i<aryLen; i++){
    &nbs= p;myObjectAry.push({'width': ary.width, 'height': ary.height});
}<= br>
David Torno
Technical Director
O: 213.739.229= 0
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 O= bjects, 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 myArra= y.length, but this gives an 'undefined' error in ExtendScript.
The array has been populated with a loop in the following manner= :

for (var i=3D0; i < myWidthValues.length; i++)
<= div>{
myArray[i].width=3DmyWidthValues[i];
myArray[i].he= ight=3DmyHeightValues[i];
}

(this isn't t= he 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 th= ere a reason that an Array of Objects won't return a 'length' value?

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

Any help much appreciated!

Phil=

--

Phi= l Bearman

Phil= Bearman Creative Media Solutions=20
Motion Graphics Design

www.PhilBearman.co.uk : Nightclub=20 & Bar ~ Production, Corpor= ate=20 & Events ~ DVD Products 


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


= --Apple-Mail-CF4C1F38-74BF-4E30-A72E-87F6DF2BBD09--