flex直接访问服务器

时间:2022-08-14 06:23:33

1、读取指定文件里的xml;

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/mx"
        creationComplete="windowedapplication1_creationCompleteHandler(event)">
 <fx:Script>
  <![CDATA[
   import mx.events.FlexEvent;
   import mx.rpc.events.ResultEvent;
   
   protected function hs_resultHandler(event:ResultEvent):void
   {
    var myData:XML = event.result as XML;
   }
   
   protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
   {
    hs.send();
   }
   
  ]]>
 </fx:Script>
 <fx:Declarations>
  <!-- 将非可视元素(例如服务、值对象)放在此处 -->
  <s:HTTPService id="hs" result="hs_resultHandler(event)" resultFormat="e4x"
        url="http://localhost:8080/baozhi/signColorXml.xml"/>
 </fx:Declarations>
 
</s:WindowedApplication>

注:装appserv服务器。