Ciao a tutti.
qualcuno ha mai fatto una cosa del genere?
ho visto molti esempi in cui la parte xml è nello stesso file... ma come si fa quando bisogna caricare il file xml?
Io ho fatto la prima parte:
codice:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="600" height="500" viewSourceURL="/form_1/index.html">
<mx:Script><![CDATA[
import mx.collections.XMLListCollection;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import flash.events.IOErrorEvent;
private function myEventHandler(event:Event):void {
box1.visible=true;
}
public function caricamentoxml(event:Event):void {
var caricamento:URLLoader = new URLLoader();
var filecaricato:URLRequest=new URLRequest("db_xml_prodotti_short.xml");
caricamento.addEventListener(Event.COMPLETE,gestionedati);
try {
caricamento.load(filecaricato);
} catch(e:Error) {
risultato.text="caricamento non riuscito";
}
}
private function gestionedati(event:Event) {
var principale:XML=new XML(event.target.data);
var scheda_prodotto:XMLList=principale.row.products_model;
//risultato.text="caricato "+scheda_prodotto.length();
for (var i:uint=0;i<=scheda_prodotto.length();i++) {
risultato.text=scheda_prodotto.children()+"\n";
}
}
]]></mx:Script>
E adesso la parte relativa al datagrid:
codice:
<mx:TextArea x="146" y="10.95" id="risultato" width="230" height="97"/>
<mx:Panel x="10" y="146" width="580" height="344" layout="absolute" title="Box interrogazione_1" id="box1">
<mx:DataGrid x="93" y="37" width="392" height="257" id="oggetto_tabella" dataProvider="{XMLListCollection}">
<mx:columns>
<mx:DataGridColumn headerText="Codice prodotto" dataField="products_model"/>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
E qui mi sono arenato!
Possibile che nessuno sia capace a popolare una datagrid una xml esterno???
Ale