arr = new Array() myVar = "elem2" arr["elem1"] = "hello" arr["elem2"] = "hi" trace(arr[myVar])
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 Bill Abel >>Sent: Monday, March 12, 2007 3:42 PM >>To: Flashcoders mailing list >>Subject: [Flashcoders] Accessing an Associative Array >> >>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