I've figured out what's going on. The HTTPService that opens the XML
property file wasn't done before the other HTTPService was called,
referring to values that didn't exist yet. I was doing the
Alert.show() from the Result handler of the property XML file's
HTTPService, so of course it had a value.

In the Application's creationComplete handler, I had these two method
calls back to back,

getPropertiesXML();
// Now fetch the grid data, which uses values set in the above method.
useHttpService();

Instead, I put the useHttpService() call inside the Result handler of
the  HTTPService call for the XML properties file. Once it's
successfully opened the XML file, then it will call the
useHttpService() method. It works fine now.

Is this the best way to do this? Any other suggestions? Thanks.

--- In [email protected], "oneworld95" <[EMAIL PROTECTED]> wrote:
>
> Hi. I'm reading a custom properties.xml file into a Flex app but it
> gives an error when I try to set an HTTPService's url to a value from
> that file. Here's the code that fetches the XML file,
> 
> private var servicePropReader:HTTPService = new HTTPService();
> 
> private function getPropertiesXML():void {
>   this.servicePropReader.url = "global/xml/properties.xml";
>   servicePropReader.resultFormat = "e4x";
>   servicePropReader.contentType = "application/xml";
>   servicePropReader.addEventListener(ResultEvent.RESULT,
> propertyReaderResultHandler);
>   servicePropReader.addEventListener(FaultEvent.FAULT,
> propertyReaderFaultHandler);
>   servicePropReader.send();
> }
> 
> In the Result handler, I do an Alert.show() and can see the value,
> which is "http://myserver.com/ViewHandler"; (minus the double quotes).
> I then try to set an HTTPService to that value, 
> 
> this.serviceGridReader.url =
> propertiesXML.property.(name=="ViewHandler").value;
> 
> This value causes the Fault handler of the above HTTPService call to
> be fired, throwing this error: "TypeError: Error #1009: Cannot access
> a property or method of a null object reference."
> 
> But if I change the above line to be set to the string value
> "http://myserver.com/ViewHandler";, it works fine. Here's the XML file,
> 
> <properties>
>   <property>
>     <name>ViewHandler</name>
>     <value>http://myserver.com/ViewHandler</value>
>   </property>
> </properties>
> 
> What am I doing wrong? Thanks.
>


Reply via email to