[AS3]as3直接与php的交互,as与php交互源代码示例
[AS3]as3直接与php的交互,as与php交互源代码示例,as3与php,as与php交互,as与php通讯
as3
- package
- {
- import flash.display.Sprite;
- import flash.net.URLLoader;
- import flash.net.URLVariables;
- import flash.net.URLRequest;
- import flash.net.URLRequestMethod;
- import flash.events.Event;
- import flash.net.URLLoaderDataFormat;
- import flash.text.TextField;
- import flash.text.TextFormat;
- [SWF(width = "720",height = "450",backgroundColor = "#445566")]
- public class Main extends Sprite
- {
- private var myLoader:URLLoader;
- private var myRequest:URLRequest;
- private var myVar:URLVariables;
- public function Main()
- {
- Init();
- }
- private function Init()
- {
- myLoader=new URLLoader();
- myLoader.dataFormat = URLLoaderDataFormat.VARIABLES; //必须设置编码形式。默认为 URLLoaderDataFormat.TEXT
- myRequest=new URLRequest();
- myRequest.method = URLRequestMethod.POST;
- myVar=new URLVariables();
- myVar.name = "vini";
- myVar.sex = "boy";
- myVar.web = "http://www.vini123.com/";
- myVar.message = "如果没有遇见,就不会有那么多的痛疼和牵挂。涸澈之鲋。相濡以沫,何不相忘于江湖。可是,我真的忘得了么。";
- myRequest.data = myVar;
- myRequest.url = "http://localhost/amfphp/crazy/hello.php";
- myLoader.addEventListener(Event.COMPLETE,completeHandler);
- myLoader.load(myRequest);
- /*
- * 记得在php那段,编码要设置成utf-8,否则报下边的错误:
- * Error: Error #2101: 傳遞給 URLVariables.decode() 的字串必須是包含成對名稱/值之 URL 編碼的查詢字串。
- */
- }
- private function completeHandler(e:Event)
- {
- for (var i in myLoader.data)
- {
- trace(i+"*****"+myLoader.data[i]);
- }
- creatTxt(myLoader.data.name,myLoader.data.sex,myLoader.data.message,myLoader.data.web);
- }
- private function creatTxt(a:String,b:String,c:String,d:String)
- {
- var myText:TextField=new TextField();
- myText.width = stage.stageWidth * 0.6;
- myText.height = stage.stageHeight * 0.6;
- myText.x = stage.stageWidth / 2 - myText.width / 2;
- myText.y = stage.stageHeight / 2 - myText.height / 2;
- myText.border = true;
- myText.multiline = true;
- myText.wordWrap = true;
- var myFormat:TextFormat=new TextFormat();
- myFormat.size = 16;
- //myFormat.color = 0xff00ff;
- addChild(myText);
- if (b=="boy")
- {
- b = "贰货";
- }
- trace(d);
- myText.htmlText = "<font color='#0099ff'>"+"有一个叫"+"</font>" + "<font color='#ff0000'><b> " + a + " </b></font>" +"<font color='#ff8500'>"+"的"+ b + "说:"+"</font><br/>" + "<font color='#0099ff'>"+c+"</font>";
- myText.htmlText += "<br/>" + "<font color='#0099ff'>"+"这个"+"</font>" +"<font color='#ff0000'><b>"+ b +"</b></font>"+"<font color='#0099ff'>"+"的网站是:" +"</font>"+ "<font color='#0099ff'><b><a href='http://www.vini123.com'>" + d + "</font></b></a>";
- myText.setTextFormat(myFormat);
- //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示例
请稍候...