Right - myArray["hello"] = "hi"
is the same as: myArray.hello = "hi" Depends on your coding preferences. Personally, I prefer Alain's suggestion of object dot-notation syntax: myArray.hello if the array's name is variable, then: this[myArray].hello Jason Merrill Bank of America Global Technology & Operations Learning & Leadership Development eTools & Multimedia Team >>-----Original Message----- >>From: [EMAIL PROTECTED] >>[mailto:[EMAIL PROTECTED] On Behalf >>Of Alain Rousseau >>Sent: Tuesday, March 13, 2007 9:58 AM >>To: flashcoders@chattyfig.figleaf.com >>Subject: RE: [Flashcoders] Accessing an Associative Array >> >>Actually you have an Object not an Array when you define your >>variable : >> >> var myarray = { text:"Lorem ipsum" }; >> >>is the same as >> >> var myarray:Object = new Object(); >> myarray.text = "Lorem ipsum"; >> >>but with Actionscript you can access objects with the array notaion [] >> >> var i:Number = 1; >> var myMC:String = "movieClip"+i; >> >> this[myMC]._x = 26; >> >> myarray["text"] = "Lorem Ipsum"; >> >>instead of >> >> this.movieClip1._x = 26; >> >> myarray.text = "Lorem Ipsum"; >> >> >>If you really want an associative array, look at Jason's >>answer Otherwise keep on using the Object notation, but you >>will lack all the Array object specific methods >> >> >>Alain >> >>-----Original Message----- >>From: [EMAIL PROTECTED] >>[mailto:[EMAIL PROTECTED] On Behalf >>Of Andy Herrman >>Sent: 12 mars 2007 16:47 >>To: flashcoders@chattyfig.figleaf.com >>Subject: Re: [Flashcoders] Accessing an Associative Array >> >>I think this is your problem: >> >>showPopup("myarray"); >> >>You're passing showPopup a string with the value "myarray", >>not the array. >>Remove the quotes and you should be good. >> >> -Andy >> >>On 3/12/07, Bill Abel <[EMAIL PROTECTED]> wrote: >>> How do you access an associate array using a variable? >>> >>> Inside my function popup["text"]; won't access the array. I >>can't find >>> any information in the books I have Actionsript Cookbook and >>> Actionscript for Flash MX. >>> >>> Anyone dealt with this before? >>> >>> // Define the text and titles for the popups var myarray = { text: >>> "Lorem ipsum dolor sit amet ..." }; >>> >>> // Testing - this works! >>> trace(myarray["text"]); >>> >>> // Show the popup >>> function showPopup(popup) { >>> mainMap[popup].gotoAndPlay("on"); >>> mainMap[popup].label_title.text = popup["text"]; // This >>> doesn't >>work. >>> trace(popup["text"]); >>> }; >>> >>> showPopup("myarray"); >>> _______________________________________________ >>> 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 >> >> >>-- >>No virus found in this incoming message. >>Checked by AVG Free Edition. >>Version: 7.5.446 / Virus Database: 268.18.10/720 - Release >>Date: 2007-03-12 >>19:19 >> >> >>-- >>No virus found in this outgoing message. >>Checked by AVG Free Edition. >>Version: 7.5.446 / Virus Database: 268.18.10/720 - Release >>Date: 2007-03-12 >>19:19 >> >> >>_______________________________________________ >>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