Thanks for the tips. I got it working.
Michael VanDaniker wrote:
>
> You're on the right track. Remoting calls are done asynchronously, so
> code that depends on the result of an HTTPService can't be placed
> immediately after the remoting call. The data will not have loaded
> before those lines are executed.
>
> The HTTPService's result attribute defines an event handler for when
> the XML is finished loading. That is why
>
> xmlObj = XML(bookData.lastResult)
>
> performs in the manner you'd expect. What you can do is call a
> function in place of that line and do your xmlObj assignment and all
> your other processing from there.
>
> With regard to calling a function when entering a state: If you have
> some event that is causing your application to change states, why not
> call the HTTPService from within that event handler?
>
> --- In flexcoders@yahoogroups.com, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
> >
> >
> > I have a box in one state, I remove the box and then add another
> box.
> > I do this so when the box is complete, I have something to trigger
> > getting data from an xml file. (That doesn't seem right, is there a
> > better way to trigger a function on entering a State ? )
> >
> > I'm testing the data in 2 ways, 1 works and the other doesn't.
> > the HTTPservice:
> > <mx:HTTPService id="bookData" url="../media/books.xml"
> > resultFormat="e4x" result="xmlObj = XML(bookData.lastResult)" />
> >
> > When I send the service:
> > bookData.send();
> > the data is sent to this textArea
> > <mx:TextArea text="{xmlObj.toString()}"/>
> >
> > So far so good, however, if I put this other test immediately after the
> > service call, I'm getting the dreaded NULL reference error.
> >
> > trace(xmlObj.stock.(@id == "1").name);
> > Does this mean I need to check for load completion, like an event
> > listener on an UrlLoader ? (if so, How? )
> > The documentation seems to indicate it shouldn't be neccesary, so I'm
> > not even sure that's the problem
> > What's wrong ?
> >
> >
> > The xml is below
> > <?xml version="1.0" encoding="iso-8859-1"?>
> > <books>
> > <stock id="1">
> > <name>The Picasso Code</name>
> > <author>Dan Blue</author>
> > <category>Fiction</category>
> > <description>Cubist paintings reveal a secret society
> > of people who really look like that</description>
> > </stock>
> > </books>
> >