Skip to main content
November 4, 2008
Question

Array methods for a total noob…

  • November 4, 2008
  • 2 replies
  • 350 views
Well, not exactly a total noob, I’ve got an old project in lingo/shockwave (where I have over 10 years experience) that I need to convert to Flash/AS3 (where I have about a week’s experience). I’ve got the basic navigation and interface elements working but I’m getting stuck trying to extract data out of my primary data structure, a two dimensional array. An example of the first few lines of the array are attached.

My first task is to write a function that can return a new one dimensional array, brandList, that contains a unique list of manufacturers (second element of the sub-array, or tireData[2]) keeping in mind that tireData is not sorted and will contain duplicate entries for manufacturers. It seems the filter method will be part of my solution but so far I haven’t gotten anything to work. Anyone know of a good tutorial on the subject?
This topic has been closed for replies.

2 replies

November 5, 2008
The AS3 Array class has an indexOf method that makes this rather simple.
November 5, 2008
Thanks everyone. I’m gonna try the indexOf() method and see if it works for me. Sorry about the index screw up, it’s going to take a few days to get used to zero based arrays again (the first element of a lingo array is [1])
Ned Murphy
Legend
November 5, 2008
If you want the second element of the array, it is index 1, not 2. If you want to sort the results, you can use the Array.sort() method. If you want some code that does the extraction, study the following, it's one possible approach: