[AS3]AS3与PHP语言通讯实例源代码
[AS3]AS3与PHP语言通讯实例源代码
[AS3]AS3与PHP语言通讯实例源代码
- package
- {
- import flash.display.Sprite;
- import flash.events.*;
- import flash.net.NetConnection;
- import flash.net.ObjectEncoding;
- import flash.net.Responder;
- public class ASWithPHP_2 extends Sprite
- {
- private var connection:NetConnection = new NetConnection();
- private var rsp:Responder = new Responder(onSuccess, onError);
- private var phpUrl:String = "PHP地址"; //注意是字符串,而不是URLRequest
- public function ASWithPHP_2()
- {
- init();
- }
- private function init():void
- {
- connection.objectEncoding = ObjectEncoding.AMF3; //CuPlayer.com提示:选择AMF3协议
- connection.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
- connection.connect(phpUrl); //连接后台PHP地址
- connection.call("CuPlayer.com提示:PHP里面的方法", rsp);
- }
- private function onNetStatus(e:NetStatusEvent):void
- {
- switch(e.info.code) {
- case "NetConnection.Connect.Success":
- trace("CuPlayer.com提示:连接成功");
- break;
- case "NetStream.Play.StreamNotFound":
- trace("CuPlayer.com提示:没有找到:" + phpUrl);
- break;
- }
- }
- private function onSuccess(obj:Object):void {
- trace("OK:" + obj);
- }
- private function onError(_obj:Object):void {
- trace("CuPlayer.com提示:错误");
- }
- }
- }
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...