1

我正在尝试使用 httpservice 的结果填充标签。此结果来自生成 xml 的 phpscript。当我运行它时,我只是得到一个空白页。我的应用程序代码如下:

'<?xml version="1.0" encoding="utf-8"?>
 <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
           initialize="doSend()">
<fx:Script> 
    <![CDATA[
        import mx.collections.ArrayCollection;
        import mx.collections.ArrayList;
        import mx.collections.XMLListCollection;
        import mx.rpc.events.ResultEvent; 

        [Bindable]
        private var myData:XML;
        public function doSend():void 
        {
            getWatchlist.send();
        }

        protected function getXML(event:ResultEvent):void
        {
            var myData:XML = XML(event.result);
            rptWatchlist.dataProvider = new XMLListCollection(myData.movies);
        }

    ]]>

</fx:Script>
<fx:Declarations>
    <mx:HTTPService url="http://****/phpscripts/selectWatchlist.php"
                    id="getWatchlist" 
                    showBusyCursor="true" 
                    method="POST"
                    result="getXML(event)"
                    resultFormat="e4x">
        <!--todo: userid ophalen -->
        <!--<mx:request xmlns="">
            <userid>
                1
            </userid>
        </mx:request>-->
    </mx:HTTPService>
</fx:Declarations>
<mx:HBox>
    <mx:Repeater id="rptWatchlist">
        <s:Label text="{rptWatchlist.currentItem.movie}" />
    </mx:Repeater>
</mx:HBox>

'

我的 phpscript 的结果是一个 xml:

 <?xml version="1.0" encoding="utf-8" ?>
  <movies>
  <movie>
       <watched>N</watched>
       <poster_url>http://cf2.imgobject.com/t/p/w185/2lECpi35Hnbpa4y46JX0aY3AWTy.jpg</poster_url>
       <movie_title>Fight Club</movie_title>
  </movie>
  </movies>
4

1 回答 1

-1

visi http://www.adobe.com/devnet/flex/videotraining/exercises/ex2_04.html类似的例子

于 2012-11-30T18:55:13.590 回答