Re: [Flashcoders] Multidimensional Array
Hi, Sorry for the cross-post, this post was a mistake, but your reply is still greatly appreciated. CK On Apr 21, 2006, at 8:23 AM, Merrill, Jason wrote: Chris, I see you posted the same question on Flashnewbies too (tsk tsk) - so I will reply here as well: So as an alternative, how about using object arrays instead? Personally, I like that so I can use dot syntax to get my data. Multidimensional arrays have there uses, but they can also get real messy and confusing real easy. Objects with a hierarchy of properties binds related data together. var people:Array = [ {firstname:"Chris", lastname:"Kennon", age:39, location:"CA"}, {firstname:"Alice", lastname:"Miller", age:24, location:"WA"}, {firstname:"Margie", lastname:"Johnson", age:36, location:"MI"} ]; //Then, to acesss: trace(people[0].firstname) //traces "Chris" trace(people[1].firstname)//traces "Alice" trace(people[1].age) //traces "24" trace(people[2].location) //traces "MI" ...etc. This way, the data sets stay associated with themselves. You can easily loop through the data to find all the people who have the last name of "Miller" and live in CA that way. I.e. to find all the names of people who live in Michigan: //data set: var people:Array = [ {firstname:"Chris", lastname:"Kennon", age:39, location:"CA"}, {firstname:"Alice", lastname:"Miller", age:24, location:"WA"}, {firstname:"Lucy", lastname:"Adams", age:36, location:"MI"}, {firstname:"George", lastname:"Miller", age:24, location:"AZ"}, {firstname:"Margie", lastname:"Johnson", age:55, location:"MI"}, {firstname:"Jim", lastname:"Johnson", age:31, location:"MI"} ]; //find index function: function findIndex(dataset:Array, findProperty:String, findString:String):Array{ var resultsArray:Array = new Array(); for(var i=0; iThis message is for the designated recipient only and may contain privileged or confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of this e-mail by you is prohibited. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Multidimensional Array
Chris, I see you posted the same question on Flashnewbies too (tsk tsk) - so I will reply here as well: So as an alternative, how about using object arrays instead? Personally, I like that so I can use dot syntax to get my data. Multidimensional arrays have there uses, but they can also get real messy and confusing real easy. Objects with a hierarchy of properties binds related data together. var people:Array = [ {firstname:"Chris", lastname:"Kennon", age:39, location:"CA"}, {firstname:"Alice", lastname:"Miller", age:24, location:"WA"}, {firstname:"Margie", lastname:"Johnson", age:36, location:"MI"} ]; //Then, to acesss: trace(people[0].firstname) //traces "Chris" trace(people[1].firstname)//traces "Alice" trace(people[1].age) //traces "24" trace(people[2].location) //traces "MI" ...etc. This way, the data sets stay associated with themselves. You can easily loop through the data to find all the people who have the last name of "Miller" and live in CA that way. I.e. to find all the names of people who live in Michigan: //data set: var people:Array = [ {firstname:"Chris", lastname:"Kennon", age:39, location:"CA"}, {firstname:"Alice", lastname:"Miller", age:24, location:"WA"}, {firstname:"Lucy", lastname:"Adams", age:36, location:"MI"}, {firstname:"George", lastname:"Miller", age:24, location:"AZ"}, {firstname:"Margie", lastname:"Johnson", age:55, location:"MI"}, {firstname:"Jim", lastname:"Johnson", age:31, location:"MI"} ]; //find index function: function findIndex(dataset:Array, findProperty:String, findString:String):Array{ var resultsArray:Array = new Array(); for(var i=0; ihttp://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] Multidimensional Array
Yes it is legitimate The correct method would depend on what for mat your data previously existed in before placing it in the array -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of CK Sent: Friday, 21 April 2006 11:13 AM To: Flashcoders mailing list Subject: [Flashcoders] Multidimensional Array Hi All, Experimenting with Multidimensional Arrays, would the following be the correct method for populating? [code] //Personal data multidimensional array. var pData:Array = [["lname", "fname"], ["age", "location"]]; // //trace(pData); // //trace(pData[0]); // //trace(pData[1]); pData[0][0] = "Kennon "+"Miller "+"Johnson"+"\n"; pData[0][1] = "Christopher "+"Alice "+"Margie"+"\n"; pData[1][0] = "39 "+"24 "+"36 "+"\n"; pData[1][1] = "CA "+"WA "+"MI"+"\n"; // trace(pData); [/code] Return True, CK Principal/Designer/Programmer -Bushidodeep http://bushidodeep.com/ __ "Knowing is not enough, you must apply; willing is not enough, you must do." ---Bruce Lee ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com