I have some XML data and I would like to do a few things with it. I have a datagrid with a master list of materials and a combobox with the names the materials. I want to do a few things, load up variables depending on what name I select in the combobox. If I select a material i would like to load up the corosponding variables for that xml item so I can work with them. If i select a certian material then the width height and cost for that item are loaded into variables to calculate.
I also would like to have multiple comboboxes read from the same xml file and filter out information based on type. I want to use this one list to feed multiple data points. So if i have two combo boxes I would like one of them to be fed information but only from a particular type. Any help with this?
import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;
import fl.controls.ScrollPolicy;
master.addColumn("Material");
master.addColumn("Type");
master.addColumn("Width");
master.addColumn("Length");
master.addColumn("Cost");
var materialsXML:XML;
var loader:URLLoader = new URLLoader(new URLRequest("master_materials.xml"));
loader.addEventListener(Event.COMPLETE, onLoaded);
function onLoaded(e:Event):void
{
materialsXML = new XML(e.target.data);
var xml:XML= new XML(loader.data);
var itemList:XMLList= xml..item;
var len:int=itemList.length();
for(var i:int=0; i<len; i++)
{
material_cb.addItem( { label: materialsXML.item.name*} );
master.addItem({Material:itemList*.name,
Width:itemList*.wide,
Length:itemList*.long,
Cost:itemList*.cost,
Type:itemList*.type});
}
}
master.columns[0].width = 100;
master.columns[1].width = 60;
master.columns[2].width = 20;
master.columns[3].width = 20;
master.columns[4].width = 20;
<?xml version="1.0" encoding="ISO-8859-1"?>
<Materials>
<item>
<name>Ritrama UV Gloss</name>
<type>Lamination Film</type>
<wide>54</wide>
<long>150</long>
<cost>210</cost>
</item>
<item>
<name>Ritrama UV Matte</name>
<type>Lamination Film</type>
<wide>54</wide>
<long>150</long>
<cost>210</cost>
</item>
<item>
<name>Arlon Clear Focus 8932</name>
<type>Lamination Film</type>
<wide>54</wide>
<long>150</long>
<cost>350</cost>
</item>
<item>
<name>Arlon Clear Focus 1900</name>
<type>Lamination Film</type>
<wide>54</wide>
<long>150</long>
<cost>350</cost>
</item>
<item>
<name>Arlon GTX 2500</name>
<type>3.5mil Cal Vinyl</type>
<wide>54</wide>
<long>150</long>
<cost>350</cost>
</item>
<item>
<name>Arlon GTXR 2500</name>
<type>3.5mil Cast Vinyl</type>
<wide>54</wide>
<long>150</long>
<cost>350</cost>
</item>
<item>
<name>12mm PVC</name>
<type>Substrate</type>
<wide>48</wide>
<long>96</long>
<cost>75</cost>
</item>
<item>
<name>9mm PVC</name>
<type>Substrate</type>
<wide>48</wide>
<long>96</long>
<cost>60</cost>
</item>
<item>
<name>5mm PVC</name>
<type>Substrate</type>
<wide>48</wide>
<long>96</long>
<cost>45</cost>
</item>
</Materials>