Here is not much to say, it should be easy to see understand! There's no use of textarea to datagrid!. :-) Just learn!
Import Mx.remoting.Service;
Import Mx.services.Log;
Import Mx.rpc.RelayResponder;
Import mx.rpc.FaultEvent;
Import mx.rpc.ResultEvent;
Import Mx.remoting.PendingCall;
Import Mx.remoting.debug.NetDebug;
Import Mx.controls.Alert; Join alert to pop up a message
Initialize a Logger
Mx.remoting.debug.NetDebug.initialize (); Initialize the NCD
var mylogger:log = new Log (log.debug, "logger1");
Override the default log handler
Mylogger.onlog = function (message:string): Void {
Trace ("mylogger-->>>" +message);
}
Set global Service
_global.svc = new Service (
"Http://localhost/amfphp/gateway.php",
MyLogger,
"Favorite",
Null
NULL);
/**
* Set the action to add a button
*/
Append_btn.onrelease = function () {
var pc:pendingcall = svc.append (Webname_txt.text,url_txt.text); The Append method in calling PHP
Pc.responder = new Relayresponder (This, "Append_result", "OnError");
Webname_txt.text = Url_txt.text = ""; Empty text box
}
Append_result = function (re:resultevent) {//Add button response result
var id = re.result;
if (ID!= "error") {
Mx.controls.Alert.show ("Save:" +id+ "-> Success", "Debug message", Alert.yes, _root, False, "Prueba", Alert.ok);
Refresh_data (); Refreshing data
}
else {
Mx.controls.Alert.show ("Technical reason not saved", "Debug message", Alert.yes, _root, False, "Prueba", Alert.ok);
}
}
/***
* Refresh button
*/
Refresh_btn.onrelease = function () {
Favorite_dg.removeallcolumns ();
Refresh_data ();
}
/**
* Refresh Data
*/
function Refresh_data () {
var pc:pendingcall = Svc.get_data ();
Pc.responder = new Relayresponder (This, "Getdata_result", "OnError");
}
/***
* Receive data display
*/
function Getdata_result (re:resultevent) {
var rs = Re.result;
Favorite_dg.columnnames = ["Id_pk", "WebName", "url", "timeline"];
Favorite_dg.dataprovider = RS;
/* Traversal method
f = rs.length; Number of library sets size
for (var i=0; i<f; i++) {
Favorite_dg.additem ({id_PK:rs.getItemAt (i). ID_PK, Webname:rs.getItemAt (i). WebName, Url:rs.getItemAt (i). URL, Timeline:rs.getItemAt (i). Timeline});
}
*/
}
/***
* ERROR:-(
*/
function OnError (rs:faultevent) {
Mx.remoting.debug.NetDebug.trace ({level: ' None ', message: "There is a problem:" + fault.fault.faultstring});
}
Refresh_data (); Initial data
Stop ();