Return-Path: Received: from mail-la0-f43.google.com ([209.85.215.43] verified) by media-motion.tv (CommuniGate Pro SMTP 4.2.10) with ESMTP-TLS id 5451458 for AE-List@media-motion.tv; Wed, 23 Apr 2014 22:10:56 +0200 Received: by mail-la0-f43.google.com with SMTP id c6so1242419lan.30 for ; Wed, 23 Apr 2014 13:10:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=OjiUdnX0yX6euGWBXo8qVfcwUa6d2i8s+Blll+pA/9I=; b=SFOAuZ2916DExsLXXBgs+mjPu50MxeYEe/5QzOxqddSiQgD1wWdL3cjt9a27QbmLK+ gg4tU3oJkgrQrcrow3kQrnaVAqCRZFVXJMboCT0zafOfvMLgwfylCaF5LcHYMI6LQoOT jQ6OLuzhX0Mw1BpviI+GuCEg2b0BRDp+sK1RNqemJPt7pEjhWbEAzlgoptRW1YiP9EAa nt6eAL0QJDoMdTm2pf657HncgTNYMDFk22fD+RCx9rRu6xeUygs56U3tWNjFFAjbtbMu xaUXGa5exT7+CrfGt2u9hN7iLcnoymamGGxod2JMjXgexHyqyKbaIp6inCBHbVEBN0Oq 4hHA== X-Gm-Message-State: ALoCoQmteitGraZFEtjiTUMYFFUMDKp7HGWUn71DjBRa/Ehken2VEC8boNuC0Kw6N9g5hh2bvTH0 MIME-Version: 1.0 X-Received: by 10.152.197.98 with SMTP id it2mr162625lac.53.1398283855610; Wed, 23 Apr 2014 13:10:55 -0700 (PDT) Received: by 10.114.5.194 with HTTP; Wed, 23 Apr 2014 13:10:55 -0700 (PDT) In-Reply-To: References: Date: Wed, 23 Apr 2014 21:10:55 +0100 Message-ID: Subject: Re: [AE] Extendscript Question - Array length problem From: Phil Bearman To: After Effects Mail List Content-Type: multipart/alternative; boundary=001a113441ae8258f504f7bb5404 --001a113441ae8258f504f7bb5404 Content-Type: text/plain; charset=ISO-8859-1 Ah that's sorted it! Thanks Dan :-) (And thank you David for the ExtendScript tutorial series you made, as that is what gave me the confidence to give this scripting project a go!) Cheers, Phil -- *Phil Bearman* *Phil Bearman Creative Media Solutions* Motion Graphics Design *NEW! Video DJ Toolkit Volume 2 - Occasions: http://philbearman.co.uk/shop/vdj-toolkit-2/ * www.PhilBearman.co.uk : Nightclub & Bar ~ Production, Corporate & Events ~ DVD Products 0161 236 2581 - 9am-5pm, Monday-Friday This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this E-Mail. Please notify the sender immediately by E-Mail if you have received this E-Mail by mistake and delete the E-Mail from your system. E-Mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message or attached documents or for any damage suffered by your computer system caused by any errors or viruses contained in the E-Mail message or any attached documents. On 23 April 2014 20:58, Dan Ebberts wrote: > You're defining textLineObjectArray as an object. Try defining it as an > array: > > var textLineObjectArray = []; > > > Dan > > *From:* Phil Bearman > *Sent:* Wednesday, April 23, 2014 12:49 PM > *To:* After Effects Mail List > *Subject:* Re: [AE] Extendscript Question - Array length problem > > Hi David, thanks for the reply. Yes, it's populating the array as > expected. Here's a better example script. This is a simplified version of > the actual script I'm using, but demonstrates the problem if you run it in > ExtendScript Toolkit (it should pop up an alert box giving the length of > the array but instead says ''undefined'). > > //~ Declare array (which will be populated with objects) > var textLineObjectArray = {}; > > var textLine="Sample"; > //~ Split string into array of characters > var textLineArray = textLine.split(''); > //~ Iterate through array and for each character, create an object > for (var i = 0; i < textLineArray.length; i++){ > //~ Add character name to object > textLineObjectArray[i]={name:textLineArray[i]} > } > //~ output length of array of objects > alert(textLine1ObjectArray.length); > > Can you see any problems with this? > > Phil > > -- > > *Phil Bearman* > > *Phil Bearman Creative Media Solutions* > Motion Graphics Design > > *NEW! Video DJ Toolkit Volume 2 - Occasions: > http://philbearman.co.uk/shop/vdj-toolkit-2/ > * > > www.PhilBearman.co.uk : Nightclub & Bar ~ Production, > Corporate & Events ~ DVD Products > > 0161 236 2581 - 9am-5pm, Monday-Friday > > This message contains confidential information and is intended only for > the individual named. If you are not the named addressee you should not > disseminate, distribute or copy this E-Mail. Please notify the sender > immediately by E-Mail if you have received this E-Mail by mistake and > delete the E-Mail from your system. E-Mail transmission cannot be > guaranteed to be secure or error-free as information could be intercepted, > corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. > The sender therefore does not accept liability for any errors or omissions > in the contents of this message or attached documents or for any damage > suffered by your computer system caused by any errors or viruses contained > in the E-Mail message or any attached documents. > > > On 23 April 2014 18:39, David Torno wrote: > >> 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> myObjectAry.push({'width': ary.width, 'height': ary.height}); >> } >> >> David Torno >> Technical Director >> http://www.ghosttownmedia.com >> O: 213.739.2290 >> C: 818.391.6060 >> -------------------- >> http://aeioweyou.blogspot.com >> >> "The most useless day is that in which we do not laugh" >> -Charles Field >> >> On Apr 23, 2014, at 9:29 AM, Phil Bearman 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 >> >> >> >> > --001a113441ae8258f504f7bb5404 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Ah that's sorted it! Thanks Dan :-)

(And thank you David for the ExtendScript tutorial series you made, as tha= t is what gave me the confidence to give this scripting project a go!)

Cheers,
Phil

--

Ph= il Bearman

Phi= l Bearman Creative Media Solutions=20
Motion Graphics Design

NEW! &n= bsp;Video DJ Toolkit Volume 2 - Occasions: http://philbearman.co.uk/sh= op/vdj-toolkit-2/

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

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

This message=20 contains confidential information and is intended only for the individual= named.=20 If you are not the named addressee you should not disseminate, distribute= or=20 copy this E-Mail. Please notify the sender immediately by E-Mail if you h= ave=20 received this E-Mail by mistake and delete the E-Mail from your system. E= -Mail=20 transmission cannot be guaranteed to be secure or error-free as informati= on=20 could be intercepted, corrupted, lost, destroyed, arrive late or incomple= te,=20 or contain viruses. The sender therefore does not accept liability for an= y errors=20 or omissions in the contents of this message or attached documents or for= any=20 damage suffered by your computer system caused by any errors or viruses c= ontained=20 in the E-Mail message or any attached documents.



On 23 April 2014 20:58, Dan Ebberts <debberts@comcast.net> wrote:
You’re defining textLineObjectArray as an object. Try defining i= t as an=20 array:
 
var textLineObjectArray =3D [];
 
 
Dan
 
Sent: Wednesday, April 23, 2014 12:49 PM
Subject: Re: [AE] Extendscript Question - Array length=20 problem
 
Hi David, thanks for the reply.  Yes, it's populating the arr= ay as=20 expected.  Here's a better example script.  This is a simplif= ied=20 version of the actual script I'm using, but demonstrates the problem if= you run=20 it in ExtendScript Toolkit (it should pop up an alert box giving the length= of=20 the array but instead says ''undefined').
 
//~ Declare array (which will be populated with objects)
var textLineObjectArray =3D {};
 
var textLine=3D"Sample";
//~ Split string into array of characters
var textLineArray =3D textLine.split('');
//~ Iterate through array and for each character, create an object
for (var i =3D 0; i < textLineArray.length; i++){
     //~ Add  character name to object
       =20 textLineObjectArray[i]=3D{name:textLineArray[i]}
}
//~ output length of array of objects
alert(textLine1ObjectArray.length);
 
Can you see any problems with this?
 
Phil
 
--

Ph= il=20 Bearman

Phil Bearman Creative Media=20 Solutions
Motion Graphics Design

NEW!&nb= sp; Video=20 DJ Toolkit Volume 2 - Occasions: http://philbearman.co.uk/shop/vdj-toolkit-= 2/

www.PhilBearman.co.uk = : Nightclub &a= mp; Bar ~ = Production, Corporate &=20 Events ~ D= VD=20 Products

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

On 23 April 2014 18:39, David Torno <torno@sy= defxink.com> wrote:

You should still be able to get the length of the array using length= .=20 Object or item based. I would verify that the array keys (.width and .hei= ght)=20 are actually populated correctly within the array. I usually make my obje= ct=20 arrays a little different and more literal like this. Not that it's r= ight or=20 wrong, just different option.
 
for(var i=3D0; i<aryLen; i++){
     myObjectAry.push({'width': ary.widt= h, 'height':=20 ary.height});
}

David Torno=20
Technical Director
--------------------

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

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

Hi all, =20
 
I'm doing some scripting in AE, and need to iterate through an= Array of=20 Objects, so need to find out the number of items in the array in order = to=20 set up the loop.
 
I had expected to be able to get the number of items using=20 myArray.length, but this gives an 'undefined' error in ExtendSc= ript.
 
The array has been populated with a loop in the following manner:<= /div>
 
for (var i=3D0; i < myWidthValues.length; i++)
{
myArray[i].width=3DmyWidthValues[i];
myArray[i].height=3DmyHeightValues[i];
}
 
(this isn't the real code, just a simplified example)
 
And the array is functioning as expected (so for example=20 myArray[2].width gives the result I expect).
 
Is there a reason that an Array of Objects won't return a '= ;length'=20 value?
 
(I know this question would be better suited to a general javascri= pt=20 forum, but I've trawled internet forums to no avail, and thought I&= #39;d ask=20 here first in case it's a quirk specific to ExtendScript).
 
Any help much appreciated!
 
Phil
 
--

Phil Bearman Creative Media=20 Solutions
Motion Graphics Design

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


0161 236 2581 - 9am-5pm, Monday-Friday
<= /p>

 

 

--001a113441ae8258f504f7bb5404--