标签:
【flex与php通信】预览截图
在线预览地址: http://rj.8634.com/xiaoshandong/flexandphp/FlexApplication3.html
代码下载地址:http://rj.8634.com/xiaoshandong/flexandphp/FlexApplication3.zip
说明: php文件请拷贝到根目录下使用,visual studio 需安装 Amethyst 插件(开发Flex)。
【flex与php通信】开发截图
【flex与php通信】源代码
FlexApplication3.mxml
<?xml version="1.0" encoding="utf-8"?> <s:Application height="600" width="800" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" click="application_click(event)"> <fx:Script source="FlexApplication3.designer.as"/> <s:Button id="Button2" height="22" width="117" label="Get" x="160" y="173" name="Button" click="button2_click(event)"/> <s:TextArea id="text" height="68" width="307" x="78" y="92" name="TextArea"/> <s:Label id="Label1" height="18" width="143" text="服务器上返回的数据" x="86" y="67" name="Label"/> </s:Application>
FlexApplication3.designer.as
// // Amethyst Designer file for FlexApplication3.mxml // import flash.accessibility.*; import flash.debugger.*; import flash.display.*; import flash.errors.*; import flash.events.*; import flash.external.*; import flash.filters.*; import flash.geom.*; import flash.media.*; import flash.net.*; import flash.printing.*; import flash.profiler.*; import flash.system.*; import flash.text.*; import flash.ui.*; import flash.utils.*; import flash.xml.*; import mx.events.*; import mx.controls.Alert; import spark.effects.easing.EaseInOutBase; //URLRequest含有网址的请求链接 private var urlrequest:URLRequest = new URLRequest("http://rj.8634.com/getIp.php"); //URLVariables存放参数数据 private var urlvariables:URLVariables = new URLVariables(); //request必须在loader上才能启动 private var urlloader:URLLoader = new URLLoader(); [AmethystDelegate("application_click")] private function application_click(event:flash.events.MouseEvent):void { } //获取PHP数据 private function callphp():void { urlvariables.message = "hello"; urlrequest.data = urlvariables; urlrequest.method = URLRequestMethod.POST; urlloader.addEventListener(Event.COMPLETE, changevalue); urlloader.load(urlrequest); } private function changevalue(event:Event) { text.text = urlloader.data; } [AmethystDelegate("button2_click")] private function button2_click(event:flash.events.MouseEvent):void { callphp(); }
php后台代码
<?php $para = $_POST[‘message‘]; echo $para.‘ ‘.$_SERVER[‘REMOTE_ADDR‘]; ?>
标签:
原文地址:http://www.cnblogs.com/ffmpeg/p/4378988.html