Groups | Blog | Home
all groups > flash actionscript > february 2005 >

flash actionscript : dynamically setting an object property


Steve Longley
2/10/2005 9:30:54 PM
I am reading in an XML file and I want all the values to be read in as object
properties and associated values. I have read in the XML file and now wish to
assign an attribute of my XML as an object property and the value to be its
value. languagedata =
{language_xml.firstChild.childNodes[counter].attributes.variable :
language_xml.firstChild.childNodes[counter].firstChild.nodeValue}; }
languagedata is my object, the first value is the property name and the second
value I want to be my value of the property. any ideas what I have done wrong?
NSurveyor
2/10/2005 9:33:56 PM
You'll have to use array syntax. someObj["someProperty"] = someValue; which is
equivalent to: someObj.someProperty = someValue. So something like this:

languagedata = new Object();

languagedata[language_xml.firstChild.childNodes[counter].attributes.variable]=la
nguage_xml.firstChild.childNodes[counter].firstChild.nodeValue
AddThis Social Bookmark Button