RE: [flexcoders] indexed array of associative array: ideas to add elements to associative array?

2007-01-08 Thread Gordon Smith
Tracy Spratt has answered your question in another post, but I just want
to mention that it would be more efficient to write

 

var myData:Array = [ { dataType: 3, timestamp: 0 },

  { dataType: 1, timestamp: 0 },

  { dataType: 2, timestamp: 0 },

  { dataType: 4, timestamp: 0 } ];

 

instead of a sequence of push() calls.

 

- Gordon

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of tinkiknit
Sent: Monday, January 08, 2007 7:29 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] indexed array of associative array: ideas to add
elements to associative array?

 

Hello...

Stuck on another issue here. Searched the archive but I didn't really 
see anything that I could use using AS3.0. I am quite a newbie to 
AS3.0, not a newbie to programming, but I'm stumped since I haven't 
done much with associative arrays.

Here is what I have: indexed array of associative arrays.

example:

var myData: Array = new Array();

myData.push({dataType: 3, timestamp: 0});
myData.push({dataType: 1, timestamp: 0});
myData.push({dataType: 2, timestamp: 0});
myData.push({dataType: 4, timestamp: 0});

What I need to do is add a new element to the associative array based 
on the dataType value: 

for the first element in my example, I'd like to add {series3 : value} 
to the associative array.

this array will be eventually used as a dataprovider for a PlotSeries.

thanks for any suggestions!

Christine

 



RE: [flexcoders] indexed array of associative array: ideas to add elements to associative array?

2007-01-08 Thread Tracy Spratt
If I am understanding your question correctly:

myData[0].series3 = value;

 

Another way to think of an associative array is as a dynamic Object.

 

Do you mean you need to search the indexed array to find the element
where dataType == 3?

 

You'll just need to do that in a for loop.

 

Tracy

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of tinkiknit
Sent: Monday, January 08, 2007 10:29 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] indexed array of associative array: ideas to add
elements to associative array?

 

Hello...

Stuck on another issue here. Searched the archive but I didn't really 
see anything that I could use using AS3.0. I am quite a newbie to 
AS3.0, not a newbie to programming, but I'm stumped since I haven't 
done much with associative arrays.

Here is what I have: indexed array of associative arrays.

example:

var myData: Array = new Array();

myData.push({dataType: 3, timestamp: 0});
myData.push({dataType: 1, timestamp: 0});
myData.push({dataType: 2, timestamp: 0});
myData.push({dataType: 4, timestamp: 0});

What I need to do is add a new element to the associative array based 
on the dataType value: 

for the first element in my example, I'd like to add {series3 : value} 
to the associative array.

this array will be eventually used as a dataprovider for a PlotSeries.

thanks for any suggestions!

Christine