0

我正在使用 Flash Builder 4.6 制作一个 Flex 移动应用程序,我对想要实现的功能有疑问。

我有一个声明:

<s:HTTPService id="getXMLFile" fault="trace('No CCR found!')" result="getPatient(event)"
                       resultFormat="object" url="assets/CCR1.xml"/>

但这仅指向一个文件,并且必须输入。现在已经如何更改 url 并再次执行请求。

getXMLFile.url = "assets/CCR2.xml";
getXMLFile.send();

但我希望有某种功能来检查“资产”包中的所有文件以及每个文件的此代码部分。所以我想要这样的东西:

for(var file:string in assets) {
getXMLFile.url = "assets/" + file;
getXMLFile.send();
}

谢谢

4

1 回答 1

0
<fx:Script>
        <![CDATA[
            import mx.rpc.events.FaultEvent;
            import mx.rpc.events.ResultEvent;



        //Create one xml having all URL, which you can parse on Flex side. Collect all URL in Array (ex:- fileArray), 
        //than you can loop it. You can call parseXML on creationComplete of your application.
        private var fileArray:Array = new Array();
        private var count:int = 0;

        //Collect all URL in this fileArray.
        private function parseXML():void
        {
            //parse XML and puch URL in fileArray
            // xmlLength var is xml length.
            var xmlLength:int;
            for(var i:int;i<xmlLength ;i++)
            {
                var URL:String = "";
                //URL = parse Value from XML; 
                fileArray.push(URL);
            }
            sendRequest();
        }

        private function sendRequest():void
        {
            getXMLFile.url = fileArray (count);
            getXMLFile.send();
        }

        private function getPatient(event:ResultEvent):void
        {
            //If Success request for Next Patient
            requestForNextPatient();
        }

        private function faultHandler(event:FaultEvent):void
        {
            //If fault request for Next Patient 
            requestForNextPatient();
        }

        private function requestForNextPatient():void
        {
            //Request for Next Patient
            count++;
            if(count > fileArray.length)
                sendRequest():
        }

        ]]>
    </fx:Script>

    <s:HTTPService id="getXMLFile" fault="faultHandler(event)" result="getPatient(event)" resultFormat="object" />

这可能会帮助你......

于 2012-05-17T05:41:03.333 回答