Assign XML node values dependent on "id" attribute in the XML file

Here is what I am needing to do:
I have anywhere from 8-20 MCs (objects) on a screen. Each may or may not be visible, and each will be in a different location, independent of other MCs. The XML will assign values (X,Y, alpha, rotation, loadMovie, color, etc.) to each clip.

I know how to hard code each MC to the XMLNode in the file, but am wanting to have the id attribute (“id=object1”, “id=object2”, etc.) to determine which nodes/children to pull values from. IE, my MC called “quoteOfTheDay”, I want to read the values from the XML node with the id=“quoteOfTheDay”. And so on…

Does anyone have an idea how to do this? I’m thinking a loop that pulls all attributes named id, or something?

anyone…

thanks

my XML
////////////////////////////////////////////
<objects backgroundImage=“bg1.jpg” >
<object id=“object1”>
<visible>1</visible>
<xPos>80</xPos>
<yPos>40</yPos>
<alpha>80</alpha>
<textContent>Number 1</textContent>
</object >
<object id=“object2”>
<visible>1</visible>
<xPos>400</xPos>
<yPos>40</yPos>
<alpha>20</alpha>
<textContent>Number 2</textContent>
</object >
<object id=“object3”>
<visible>1</visible>
<xPos>500</xPos>
<yPos>130</yPos>
<alpha>80</alpha>
<textContent>Number 3</textContent>
</object >

</objects>

////////////////////////////////////////////

This looks like a job for idMap…

[AS]var props_xml:XML = new XML();
var props_obj:Object = new Object();
//
props_xml.ignoreWhite = true;
props_xml.onLoad = function(success) {
if (success) {
var temp_xml = new XML();
temp_xml.ignoreWhite = true;
temp_xml.parseXML(props_xml.toString());
props_obj = temp_xml.idMap;
//
for (var props in props_obj) {
trace(props_obj[props]);
trace("

");
}
}
};
//
props_xml.load(“objects.xml”);[/AS]

Very cool! :!:

One question though…
how do I pull from the child nodes contained in each id node?

each property of the props_obj is itself an xml object. so you can access the nodes just as you would with any xml… Something like this would do the trick:
[AS]var props_xml:XML = new XML();
var props_obj:Object = new Object();
//
props_xml.ignoreWhite = true;
props_xml.onLoad = function(success) {
if (success) {
var temp_xml = new XML();
temp_xml.ignoreWhite = true;
temp_xml.parseXML(props_xml.toString());
props_obj = temp_xml.idMap;
// attach a movie clip to test it out
attachTest();
}
};
//
function attachTest():Void {
var test:MovieClip = this.attachMovie(“test_mc”, “tmc”, this.getNextHighestDepth(), {props:props_obj.object1});
// set properties
test._visible = (Number(test.props.childNodes[0].firstChild.toString()) > 0);
test._x = Number(test.props.childNodes[1].firstChild.toString());
test._y = Number(test.props.childNodes[2].firstChild.toString());
test._alpha = Number(test.props.childNodes[3].firstChild.toString());
test.someText_txt.text = test.props.childNodes[4].firstChild.toString();
}
//
props_xml.load(“objects.xml”);[/AS]