Flash background Data Connection (PHP article) php&flash Favorites-amfphp Implementation +mysql

Source: Internet
Author: User

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 ();

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.