flex与php通信(截图、在线预览、源代码下载)

【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‘];
?>

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。