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.
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
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.
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.
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