0
votes

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

1
How is the HTTPService being called? What happens when you debug? Any errors? - J_A_X
the HTTPService calls are directly after my </mx:Script> and the only warnings I get during debug are all deal with a different part of the application (called after the directorsprep.xml file) which works just fine. Also, all the warnings I get are "unable to bind" warnings. - Brds
It's tough to debug "Doesn't work." You need to expand on that. Are you getting a runtime error? A compile time error? Or no error? Are there problems with the data coming back? What is being returned? Do you have a break point in the result handler and have you reviewed the data? Did you use a tool such as the Flash Builder Network Monitor to view the packets being sent back and forth? - JeffryHouser
The rest of the application loads fine. No errors or warnings are given when i save the application. the HTTPService calls are made right below my <mx:Script> portion of the mxml file. After the HTTPService tags are called, there are some layout canvases, then 2 repeaters are called (i know - i know "repeaters are the devil"... but it's too late in the project to change it now). The information in the directorsprep.xml file is supposed to feed the first repeater and the information from projectsHttp feeds the second. The second repeater runs fine and works great. - Brds
Shouldn't the createPhase function being throwing an alert as soon as the HTTPService is done loading? - Brds

1 Answers

1
votes

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!