//El xml
Código :
<xml> <not> <titulo>n1tit</titulo> <texto>n1txt</texto> </not> <not> <titulo>n2tit</titulo> <texto>n2txt</texto> </not> <not> <titulo>n3tit</titulo> <texto>n3txt</texto> </not> </xml>
//El mxml
Código :
<?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="dgXMLrqst.send()"> <mx:HTTPService id="dgXMLrqst" url="xml/xml.xml" useProxy="false"/> <mx:Script> <![CDATA[ [Bindable] public var selectedEntry; //selectedEntry=event.target.selectedItem //selectedEntry=event.currentTarget.selectedIndex; ]]> </mx:Script> <mx:DataGrid x="20" y="20" id="dg" width="231" height="167" dataProvider="{dgXMLrqst.lastResult.xml.not}" change="selectedEntry=event.target.selectedItem" selectedIndex="1"> <mx:columns> <mx:DataGridColumn headerText="col1" dataField="titulo"/> <mx:DataGridColumn headerText="col2" dataField="texto"/> </mx:columns> </mx:DataGrid> <mx:TextArea x="259" y="41" width="199" height="88" text="{selectedEntry.texto}" htmlText="true" wordWrap="true" editable="false"/> </mx:WindowedApplication>
Si prueban el código van a ver que el selector se posiciona en el 2do registro, hasta ahi bien, si clickean cualquiera de los registros se mostrará en el cuadro de texto el atributo "texto". Pero yo quiero tambien que cuando arranca la aplicación muestre en el cuadro de texto el atributo "texto" segun el valor del selectedIndex que se coloque. Como se hace?, gracias.