Home > Backend Development > PHP Tutorial > Using Flash AS3 to obtain remote PHP data instance_PHP tutorial

Using Flash AS3 to obtain remote PHP data instance_PHP tutorial

WBOY
Release: 2016-07-21 14:54:21
Original
1051 people have browsed it

Here is an example of using Flash AS3 to obtain remote PHP data. The data is obtained from the remote URL and then displayed in the Flash form text box. The example code is as follows:

1, AS3 part [Download]

package {
import flash.display.MovieClip;
import flash.events.*;
import flash.net.*;
import flash.text.*;
public class Main extends MovieClip {
public function Main() {
var request:URLRequest = new URLRequest("http://t.biuuu.com/index.php?nocache=");
request.method = URLRequestMethod.GET;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.load( request);
function completeHandler(evt:Event) {
b_title.text = evt.target.data.username;
b_email.text = evt.target.data.email;
}
}
}
}

The implementation steps are as follows:

1. Get a URLRequest object instance

var request:URLRequest = new URLRequest(http://t.biuuu.com/index.php?nocache=);

Second, specify the method implemented by the request object, such as GET

request.method = URLRequestMethod.GET;

Three, get a URLLoader object instance

var loader:URLLoader = new URLLoader();

Four, set the data format of the loader object

loader.dataFormat = URLLoaderDataFormat.VARIABLES;

Fifth, set up a listening event when the PHP data acquisition is completed

loader.addEventListener(Event.COMPLETE, completeHandler);

6. Loading request

loader.load(request); To put it simply, it is to first clarify the attributes of the request URL, such as path address, request method, etc., and then set the implementation method of the returned data, such as data format , processing methods, etc.

2. PHP part [The path is http://t.biuuu.com/index.php, which can be modified according to the actual situation]

Pay attention to the assembly form of the data, similar to parameter = value. If there are multiple parameters, use & split

As shown in the above example, you can realize a simple function of using FLASH AS3 to remotely obtain PHP data. With this knowledge, you can start to implement a simple website based on AS3+PHP.

Click to download: as3_php.rar

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/364620.htmlTechArticleHere is an example of using Flash AS3 to get remote PHP data, by getting the data from the remote URL, and then displaying it in Flash In the form text box, the example code is as follows: 1. AS3 part [Download...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template