无法理解 Flex 中的异常?

发布于 2024-08-16 11:52:20 字数 3070 浏览 4 评论 0原文

我正在尝试 learn.adobe.com 网站中提供的 flickr 代码,但出现此异常:

[RPC Fault faultString="Error #1090: XML parser failure: element is malformed." faultCode="Client.CouldNotDecode" faultDetail="null"]
    at mx.rpc.http::HTTPService/http://www.adobe.com/2006/flex/mx/internal::processResult()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\http\HTTPService.as:851]
    at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:188]
    at mx.rpc::Responder/result()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:43]
    at mx.rpc::AsyncRequest/acknowledge()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:74]
    at DirectHTTPMessageResponder/completeHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:403]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

我无法理解此异常。谁能帮我解决这个问题吗?
这是我输入的代码

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
        backgroundGradientColors="[0xFFFFFF,0xAAAAAA]" horizontalAlign="left" 
        horizontalGap="15" verticalGap="15" width="459" height="371">
    <mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.rpc.events.ResultEvent;

            [Bindable]
            public var photoBindable:ArrayCollection;
            private function requestPhotos():void{
                photoService.cancel();
                var params:Object=new Object();
                params.format = 'rss_200_enc';
                params.tags = searchTerm.text;
                photoService.send(params);
            }
            private function photoHandler(event:ResultEvent):void{
                photoBindable=event.result.rss.channel.items as ArrayCollection;
            }
        ]]>
    </mx:Script>
    <mx:HTTPService id="photoService"
        url="http://api.flickr.com/services/feeds/photos_public.gne"
        result="photoHandler(event)" />
    <mx:HBox>
        <mx:Label text="Flicker tags" />
        <mx:TextInput id="searchTerm" />
        <mx:Button label="Search" click="requestPhotos()"/>
    </mx:HBox>
    <mx:TileList width="100%" height="100%"
        dataProvider="{photoBindable}"
        itemRenderer="thumbnail">
    </mx:TileList>
</mx:Application>

这是 itemRenderthumbnail.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="75" height="75"
        horizontalScrollPolicy="off" verticalScrollPolicy="off"
        paddingBottom="5" paddingLeft="5" paddingTop="5">
    <mx:Image width="75" height="75" source="{data.thumbnail.url}" />
    <mx:Text text="{data.credits}" />
</mx:VBox>

I was trying the flickr code provided in the learn.adobe.com website, and I am getting this exception:

[RPC Fault faultString="Error #1090: XML parser failure: element is malformed." faultCode="Client.CouldNotDecode" faultDetail="null"]
    at mx.rpc.http::HTTPService/http://www.adobe.com/2006/flex/mx/internal::processResult()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\http\HTTPService.as:851]
    at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:188]
    at mx.rpc::Responder/result()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:43]
    at mx.rpc::AsyncRequest/acknowledge()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:74]
    at DirectHTTPMessageResponder/completeHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:403]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

I can't understand this exception. Can anyone help me with this?
This is the code which i have typed

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
        backgroundGradientColors="[0xFFFFFF,0xAAAAAA]" horizontalAlign="left" 
        horizontalGap="15" verticalGap="15" width="459" height="371">
    <mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.rpc.events.ResultEvent;

            [Bindable]
            public var photoBindable:ArrayCollection;
            private function requestPhotos():void{
                photoService.cancel();
                var params:Object=new Object();
                params.format = 'rss_200_enc';
                params.tags = searchTerm.text;
                photoService.send(params);
            }
            private function photoHandler(event:ResultEvent):void{
                photoBindable=event.result.rss.channel.items as ArrayCollection;
            }
        ]]>
    </mx:Script>
    <mx:HTTPService id="photoService"
        url="http://api.flickr.com/services/feeds/photos_public.gne"
        result="photoHandler(event)" />
    <mx:HBox>
        <mx:Label text="Flicker tags" />
        <mx:TextInput id="searchTerm" />
        <mx:Button label="Search" click="requestPhotos()"/>
    </mx:HBox>
    <mx:TileList width="100%" height="100%"
        dataProvider="{photoBindable}"
        itemRenderer="thumbnail">
    </mx:TileList>
</mx:Application>

This is itemRender thumbnail.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="75" height="75"
        horizontalScrollPolicy="off" verticalScrollPolicy="off"
        paddingBottom="5" paddingLeft="5" paddingTop="5">
    <mx:Image width="75" height="75" source="{data.thumbnail.url}" />
    <mx:Text text="{data.credits}" />
</mx:VBox>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

滥情稳全场 2024-08-23 11:52:20

当然,XML 或 .php 文件中存在错误,可能是空格或其他内容;检查 xml 的第一行,该行必须仅以以下语句开头:

<?xml version="1.0" encoding="utf-8"?>

我很确定您忘记导入 itemRender:

<mx:Script>
    <![CDATA[
        import mx.collections.ArrayCollection;
        import mx.rpc.events.ResultEvent;
        import itemRender; //substitute itemRender with your own itemRender.mxml file
    ]]>
</mx:Script>

无论如何,看看这个 page 即使是意大利语,代码也很容易理解。

希望有用

Of course there's an error in the XML or in the .php file, maybe blank space or something else; check the first line of xml which has to start only with the following statement:

<?xml version="1.0" encoding="utf-8"?>

I'm quite sure you forget to import the itemRender:

<mx:Script>
    <![CDATA[
        import mx.collections.ArrayCollection;
        import mx.rpc.events.ResultEvent;
        import itemRender; //substitute itemRender with your own itemRender.mxml file
    ]]>
</mx:Script>

Anyway take a look to this page even if it's italian language the code is very simple to understand.

Hope to be useful

烦人精 2024-08-23 11:52:20

我认为问题出在这个标签event.result.rss.channel.items中,它不是items,而是item
去掉多余的's'......
这个例子很好...它对我有用...您可以使用下面的代码来检查

在此处打印我的代码...我向其中添加了更多内容

FlickrPrj.mxml

    <mx:Script>
        <![CDATA[
            import mx.events.ListEvent;
            import mx.controls.Alert;
            import mx.managers.PopUpManager;
            import mx.rpc.events.ResultEvent;
            import mx.collections.ArrayCollection;

           [Bindable]
           public var photoFeed:ArrayCollection;

            public function searchFlickr():void {
                photoService.cancel();
                var params:Object = new Object();
                    params.format = 'rss_200_enc';
                    params.tags = srchTxtId.text;               
                photoService.send(params);
            }

            public function resultHandler(event:ResultEvent):void {
                photoFeed = event.result.rss.channel.item as ArrayCollection;
            }

            public function openPanel(levent:ListEvent):void {
                var panelCmpObj:panelcomp = new panelcomp();    
                   panelCmpObj.source = levent.itemRenderer.data.content.url;           
                PopUpManager.addPopUp(panelCmpObj,this,true);
            }
            public function test():void {
                Alert.show('testtest');
                }           

        ]]>
    </mx:Script>

    <mx:HTTPService id="photoService" url="http://api.flickr.com/services/feeds/photos_public.gne" result="resultHandler(event)"/>

    <mx:HBox width="362" height="24">
        <mx:TextInput id="srchTxtId"/>
        <mx:Button label="Search for pics" id="srchBtnId" click="searchFlickr()"/>
    </mx:HBox>
    <mx:TileList id="imgTileList" dataProvider="{photoFeed}" width="100%" height="100%" itemClick="openPanel(event)">   
    <mx:itemRenderer>
        <mx:Component>
          <mx:VBox width="125" height="125"
                paddingBottom="5"
                paddingLeft="5"
                paddingTop="5"
                paddingRight="5">
                <mx:Image width="75" height="75" source="{data.thumbnail.url}"/>
          </mx:VBox>
        </mx:Component>
    </mx:itemRenderer>
    </mx:TileList>

</mx:Application>

panelcomp.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
        showCloseButton="true"
        styleName="noPadding"
        creationComplete="init();"
        close="titleWindow_close(event);">
<mx:Script>
        <![CDATA[
            import mx.managers.IFocusManagerComponent;
            import mx.controls.Alert;
            import mx.core.IFlexDisplayObject;
            import mx.events.CloseEvent;
            import mx.managers.PopUpManager;

            [Bindable]
            public var source:String;

            private function init():void {
                PopUpManager.centerPopUp(this);
            }

            private function titleWindow_close(evt:CloseEvent):void {
                PopUpManager.removePopUp(evt.target as IFlexDisplayObject);
            }
        ]]>
    </mx:Script>

    <mx:Image width="379" height="261" id="imgId" source="{source}"/>
       <mx:ControlBar horizontalAlign="right" width="100%">
    </mx:ControlBar>

</mx:TitleWindow>

注意将FlickPrj.mxml 和panelcomp.mxml 放在同一目录中。

I think the problem is in this tag event.result.rss.channel.items it is not items it is item
Remove the extra 's' .....
The example is good...it worked for me...you can use this code below to check

Printing my code here...i added some more stuff to it

FlickrPrj.mxml

    <mx:Script>
        <![CDATA[
            import mx.events.ListEvent;
            import mx.controls.Alert;
            import mx.managers.PopUpManager;
            import mx.rpc.events.ResultEvent;
            import mx.collections.ArrayCollection;

           [Bindable]
           public var photoFeed:ArrayCollection;

            public function searchFlickr():void {
                photoService.cancel();
                var params:Object = new Object();
                    params.format = 'rss_200_enc';
                    params.tags = srchTxtId.text;               
                photoService.send(params);
            }

            public function resultHandler(event:ResultEvent):void {
                photoFeed = event.result.rss.channel.item as ArrayCollection;
            }

            public function openPanel(levent:ListEvent):void {
                var panelCmpObj:panelcomp = new panelcomp();    
                   panelCmpObj.source = levent.itemRenderer.data.content.url;           
                PopUpManager.addPopUp(panelCmpObj,this,true);
            }
            public function test():void {
                Alert.show('testtest');
                }           

        ]]>
    </mx:Script>

    <mx:HTTPService id="photoService" url="http://api.flickr.com/services/feeds/photos_public.gne" result="resultHandler(event)"/>

    <mx:HBox width="362" height="24">
        <mx:TextInput id="srchTxtId"/>
        <mx:Button label="Search for pics" id="srchBtnId" click="searchFlickr()"/>
    </mx:HBox>
    <mx:TileList id="imgTileList" dataProvider="{photoFeed}" width="100%" height="100%" itemClick="openPanel(event)">   
    <mx:itemRenderer>
        <mx:Component>
          <mx:VBox width="125" height="125"
                paddingBottom="5"
                paddingLeft="5"
                paddingTop="5"
                paddingRight="5">
                <mx:Image width="75" height="75" source="{data.thumbnail.url}"/>
          </mx:VBox>
        </mx:Component>
    </mx:itemRenderer>
    </mx:TileList>

</mx:Application>

panelcomp.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
        showCloseButton="true"
        styleName="noPadding"
        creationComplete="init();"
        close="titleWindow_close(event);">
<mx:Script>
        <![CDATA[
            import mx.managers.IFocusManagerComponent;
            import mx.controls.Alert;
            import mx.core.IFlexDisplayObject;
            import mx.events.CloseEvent;
            import mx.managers.PopUpManager;

            [Bindable]
            public var source:String;

            private function init():void {
                PopUpManager.centerPopUp(this);
            }

            private function titleWindow_close(evt:CloseEvent):void {
                PopUpManager.removePopUp(evt.target as IFlexDisplayObject);
            }
        ]]>
    </mx:Script>

    <mx:Image width="379" height="261" id="imgId" source="{source}"/>
       <mx:ControlBar horizontalAlign="right" width="100%">
    </mx:ControlBar>

</mx:TitleWindow>

Note put FlickPrj.mxml and panelcomp.mxml in the same directory.

单调的奢华 2024-08-23 11:52:20

这意味着加载的xml文件没有正确写入,尝试在IE(或某些xml工具,例如altova)中打开它,看看有什么问题。

It means that the xml file that was loaded was not written properly , try to open it in IE ( or some xml tool such as altova ) and see whats wrong with it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文