Collection of flash and background data exchange methods-flash remoting

Source: Internet
Author: User
Flash remoting is the most efficient among the four data interfaces!
Advantages :
1. Supports multiple data types (converting from application server data types to ActionScript );
2. The transferred data volume is large;
3. The operational efficiency is the highest among the several existing ones;
4. good support for various background services;
5. netconnection Debugger)

disadvantages :
1. flash remoting MX components needs to be installed on the flash end (this is provided for free);
2. the Flash remoting module must be installed on the background server. The modules provided by mm are J2EE and. net two versions are charged, but there are two open-source (openamf, amfphp) on the Internet;
3. it seems that remoting does not provide good support for virtual hosts (you can search Google to see if there is any solution ). // ================================================ ===================;
// Code On The Flash end: (I use as1.0 as an example. Find other versions on the MM site)
// ========================================== ===========================;
// load the remoting component code. This is required.
# include "netservices. as "
// load the code of the remoting debugging module. This is optional. Use netconnection debugger to view debugging information.
# include" netdebug. as "
If (inited = NULL) {
inited = true;
// sets the default gateway.
netservices. setdefagategatewayurl ("http: // localhost: 8500/flashservices/Gateway");
// establishes a gateway connection.
gateway_conn = netservices. creategatewayconnection ();
// get a service;
myservice = gateway_conn.getservice ("myservice", this);
}

// define the function to call the method.
function getstring (name) {
// call the getstring method of remoting.
myservice. getstring (name);
}< br> // defines the function of the returned result.
function getstring_result (result) {
// The result is the returned result;
trace (result);
}< br> // defines the function of the returned state. This is optional.
function getstring_status (error) {
trace ("getstring_status");
trace (error. code);
trace (error. description);
trace (error. details);
}

// Call a function;
Getstring ("kinglong "); // ================================================ ===================;
// Server method definition (Here we use ColdFusion component as an example. For other versions, refer to relevant materials)
// ================================================ ===================;
<! --- File name: myservice. CFC --->
<Cfcomponent displayname = "my services">
<! --- The getstring method is defined. You must set access to remote. Otherwise, flash remoting cannot call this method. --->
<Cffunction name = "getstring" Access = "remote" returntype = "string">
<Cfargument name = "name" type = "string" required = "true">
<Cfset myresult = arguments. Name & ", welcome! ">
<Cfreturn myresult>
</Cffunction>
</Cfcomponent>

Attached to the Flash remoting online help file (flash remoting livedocs), The remoting information on the MM website.

Source: Blue ideal

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.