Flex vs. PHP Communication preview
Online Preview Address: http://rj.8634.com/xiaoshandong/flexandphp/FlexApplication3.html
Code download address:http://rj.8634.com/xiaoshandong/flexandphp/FlexApplication3.zip
Description: PHP files should be copied to the root directory for use, Visual Studio will need to install the Amethyst plugin (development flex).
"Flex and PHP Communication" development
"Flex and PHP communication" source code
Flexapplication3.mxml
<?XML version= "1.0" encoding= "Utf-8"?><s:applicationHeight= "All"width= "$"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:scriptSource= "FlexApplication3.designer.as"/> <S:buttonID= "Button2"Height= "All"width= "117"label= "Get"x= " the"y= "173"name= "button"Click= "button2_click (event)"/> <S:textareaID= "text"Height= "The "width= "307"x= "+"y= "the"name= "TextArea"/> <S:labelID= "Label1"Height= "+"width= "143"text= "Data returned on the server"x= "The "y= " the"name= "Label"/></s:application>
FlexApplication3.designer.as
////Amethyst Designer file for Flexapplication3.mxml//ImportFlash.accessibility.*;ImportFlash.debugger.*;ImportFlash.display.*;Importflash.errors.*;Importflash.events.*;ImportFlash.external.*;Importflash.filters.*;Importflash.geom.*;ImportFlash.media.*;Importflash.net.*;Importflash.printing.*;ImportFlash.profiler.*;Importflash.system.*;Importflash.text.*;Importflash.ui.*;Importflash.utils.*;ImportFlash.xml.*;Importmx.events.*;ImportMx.controls.Alert;Importspark.effects.easing.EaseInOutBase;//urlrequest a request link containing a URLPrivate varUrlrequest:urlrequest =NewURLRequest ("http://rj.8634.com/getIp.php");//urlvariables storing parameter dataPrivate varUrlvariables:urlvariables =Newurlvariables ();//request must be on loader to startPrivate varUrlloader:urlloader =NewURLLoader (); [Amethystdelegate ("Application_click")]Private functionApplication_click (event:flash.events.MouseEvent):void { }//Get PHP DataPrivate functionCallphp ():void{urlvariables.message="Hello"; Urlrequest.data=Urlvariables; Urlrequest.method=Urlrequestmethod.post; Urlloader.addeventlistener (Event.complete, ChangeValue); Urlloader.load (urlrequest);}Private functionChangeValue (event:event) {Text.text=Urlloader.data;} [Amethystdelegate ("Button2_Click")]Private functionButton2_Click (event:flash.events.MouseEvent):void{callphp ();}
PHP Background Code
<? PHP $para $_post [' message ']; Echo $para. ' ‘. $_server [' REMOTE_ADDR '];? >
Flex and PHP communication (, online preview, source code download)