Código ActionScript :
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="get_info.send()"> <mx:HTTPService id="get_info" url="http://localhost/foros/get_foros.php" useProxy="false"/> <mx:HTTPService id="post_info" url="http://localhost/foros/post_foro.php" useProxy="false" method="POST" contentType="application/x-www-form-urlencoded" resultFormat="text" result="mensaje(event)"> <mx:request> <descrip>{descrip.text}</descrip> <autor>{autor.text}</autor> </mx:request> </mx:HTTPService> <mx:Script> <![CDATA[ import mx.controls.Alert; private function dblClickHandler():void { Alert.show("id="+dgrid.selectedItem.id_foro); } private function postInfo():void{ if(descrip.text=="" || autor.text=="" ) { mx.controls.Alert.show("Uno de los campos está en blanco!") } else { post_info.send() } } private function showInfo():void{ get_info.send(); dgrid.invalidateDisplayList(); } private function mensaje(evt:Event):void { if(String(post_info.lastResult)=="ok") Alert.show("Fue agregado un nuevo foro.") else Alert.show("Sorry, there was a server error!") } ]]> </mx:Script> <mx:Panel width="90%" height="520" layout="absolute" title="Foros UNEFA"> <mx:DataGrid x="20" y="20" id="dgrid" width="90%" height="350" dataProvider="{get_info.lastResult.foros.foro}" doubleClick="dblClickHandler()" doubleClickEnabled="true"> <mx:columns> <mx:DataGridColumn headerText="id" dataField="id_foro" /> <mx:DataGridColumn headerText="Foro" dataField="descrip" /> <mx:DataGridColumn headerText="Vistas" dataField="vistas" /> <mx:DataGridColumn headerText="Mensajes" dataField="mensajes" /> <mx:DataGridColumn headerText="Ultimo Post" dataField="ultimo_post_login" /> <mx:DataGridColumn headerText="Ultimo Post" dataField="ultimo_post_fecha" /> </mx:columns> </mx:DataGrid> <mx:TextInput x="20" y="380" width="424" id="descrip"/> <mx:TextInput x="20" y="410" width="424" id="autor"/> <mx:Button x="20" y="440" label="Nuevo Foro" click="postInfo(),showInfo()"/> <mx:Button x="100" y="440" label="Refresh" click="showInfo()"/> </mx:Panel> </mx:Application>
Gracias de antemano!!!