Flex 3:HTTPService 不适用于一个文件...有人看到代码有什么问题吗?

发布于 2024-11-18 15:00:49 字数 1888 浏览 4 评论 0原文

因此,我对三个不同的 XML 文件进行了三个 HTTPService 调用:

<mx:HTTPService id="projectsHttp" url="projects.xml" resultFormat="e4x" makeObjectsBindable="true" result="countProjects(event)" />
<mx:HTTPService id="studentsHttp" url="students.xml" resultFormat="e4x" makeObjectsBindable="true" result="createStudentsCollection(event)" />
<mx:HTTPService id="dprepHttp" url="directorsPrep.xml" resultFormat="e4x" makeObjectsBindable="true" result="createPhase(event)" />

前两个工作很好......但最后一个不起作用。出于测试目的,createPhase 函数如下所示:

public function createPhase(e:ResultEvent):void
{
    Alert.show("Testing");
}

另外,directorsPrep.xml 文件如下所示:

<?xml version="1.0" encoding="utf-8"?>
<directorspreps>
    <directorsprep>
        <prepid>1</prepid>
        <title>dir. prep. 1</title>
        <workingtitle>dp1 WT</workingtitle>
        <startdate>7/7/2011</startdate>
        <numdays>2</numdays>
        <positions>
            <role>1D</role>
            <role>2D</role>
            <role>1C</role>
        </positions>
    </directorsprep>
    <directorsprep>
        <prepid>2</prepid>
        <title>dir. prep. 2</title>
        <workingtitle>dp2 WT</workingtitle>
        <startdate>7/10/2011</startdate>
        <numdays>3</numdays>
        <positions>
            <role>1D</role>
            <role>2D</role>
            <role>1C</role>
            <role>GE</role>
        </positions>
    </directorsprep>
</directorspreps>

有人看到任何会阻止directorsPrep.xml 文件不加载的内容吗?

编辑: 我是个白痴...没有执行 .send(); :( 抱歉浪费了时间

So, i've got three HTTPService calls for three different XML files:

<mx:HTTPService id="projectsHttp" url="projects.xml" resultFormat="e4x" makeObjectsBindable="true" result="countProjects(event)" />
<mx:HTTPService id="studentsHttp" url="students.xml" resultFormat="e4x" makeObjectsBindable="true" result="createStudentsCollection(event)" />
<mx:HTTPService id="dprepHttp" url="directorsPrep.xml" resultFormat="e4x" makeObjectsBindable="true" result="createPhase(event)" />

The first two work great... but that last one just won't work. For testing purpose, the createPhase function looks like this:

public function createPhase(e:ResultEvent):void
{
    Alert.show("Testing");
}

Also, the directorsPrep.xml file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<directorspreps>
    <directorsprep>
        <prepid>1</prepid>
        <title>dir. prep. 1</title>
        <workingtitle>dp1 WT</workingtitle>
        <startdate>7/7/2011</startdate>
        <numdays>2</numdays>
        <positions>
            <role>1D</role>
            <role>2D</role>
            <role>1C</role>
        </positions>
    </directorsprep>
    <directorsprep>
        <prepid>2</prepid>
        <title>dir. prep. 2</title>
        <workingtitle>dp2 WT</workingtitle>
        <startdate>7/10/2011</startdate>
        <numdays>3</numdays>
        <positions>
            <role>1D</role>
            <role>2D</role>
            <role>1C</role>
            <role>GE</role>
        </positions>
    </directorsprep>
</directorspreps>

Anybody see anything that would prevent the directorsPrep.xml file from not loading?

EDIT:
I'm a moron... Didn't do the .send(); :( Sorry for the time waster

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

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

发布评论

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

评论(1

眼眸 2024-11-25 15:00:49

很难肯定地说。我在 Flex3 中创建了一个小项目,其中包含您的 XML 文件,它对我来说工作得很好。您应该添加一个fault 处理程序来了解失败的原因。如果您需要检查某些内容,请在该处理程序中放置一个断点。另外,请确保您正在调用 send() 以便加载该 XML 文件。这是对我有用的示例(包括故障处理程序)。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600">

    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.rpc.events.FaultEvent;
            import mx.rpc.events.ResultEvent;

            public function createPhase(e:ResultEvent):void
            {
                Alert.show(e.result.toString());
            }

            protected function createPhaseFailed(e:FaultEvent):void
            {
                Alert.show(e.message.toString());
            }

        ]]>
    </mx:Script>

    <mx:HTTPService id="dprepHttp" url="directorsPrep.xml" resultFormat="e4x" makeObjectsBindable="true" 
                    result="createPhase(event)" fault="createPhaseFailed(event)" /> 

    <mx:initialize>
        <![CDATA[
            dprepHttp.send();
        ]]>
    </mx:initialize>

</mx:Application>

祝你好运!

It is tough to say for sure. I created a little project in Flex3 that includes your XML file and it worked fine for me. You should add a fault handler to know why it is failing. Put a breakpoint in that handler if you need to examine things. Also, make sure that you are calling send() in order for that XML file to get loaded. Here is an example of what was working for me (including the fault handler).

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600">

    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.rpc.events.FaultEvent;
            import mx.rpc.events.ResultEvent;

            public function createPhase(e:ResultEvent):void
            {
                Alert.show(e.result.toString());
            }

            protected function createPhaseFailed(e:FaultEvent):void
            {
                Alert.show(e.message.toString());
            }

        ]]>
    </mx:Script>

    <mx:HTTPService id="dprepHttp" url="directorsPrep.xml" resultFormat="e4x" makeObjectsBindable="true" 
                    result="createPhase(event)" fault="createPhaseFailed(event)" /> 

    <mx:initialize>
        <![CDATA[
            dprepHttp.send();
        ]]>
    </mx:initialize>

</mx:Application>

Good luck!

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