|
Nope, you can’t do that. The Flash
Player, from our perspective, is single threaded. Nothing else can happen
during a loop, including receiving any data. Data calls in Flex are asynchronous.
You must either bind to the lastResult property, or handle the result data in a
handler function called from the data service tag’s result event.
You cannot handle the result in the same function that you call it. Period. setInterval() and callLater() won’t
work either. See “Handling asynchronous calls to
services” in the developers guide for more info. From: Hi all, I have
this bit of code that does some simple things, but my timing is off. What
I do is I make a webservice call to some server, and the server returns me a
string of XML. After that, I parse that string of XML into an XMLDocument
object, to use as a data provider for a repeater. That's it. Here
is a simple version of my code. WebserviceCall(); // this function returns the result as
an XML string and puts it
// into a String variable called string_result on event.COMPLETE xml_result.parseXML(string_result); my_repeater.dataProvider = xml_result; So this
al works fine when I do each one of these steps separately. But when I
try to do them in succession, I get an error on the line that tried to parse
the XML. This is because it takes a while for the server to return the
XML result and put it into string_result. So, when the application tries
to execute the next line, it tries to parse an empty string into XML, which
obviously fails on me. What I
tried already, was putting a simple loop in before the parse call to
make sure that the String is not null... while (!string_result); // wait until string is not null before
continuing ...but
this eats up my resources and crashes the browser. So, I am wondering if
there is a sleep function in ActionScript, so that I could go... while (!string_result) sleep(1); // sleep for 1 second
before repeating loop
// hopefully this won't stress the system as much So that's my plan of attack. I know that sleeps are kind of
"hack" fixes, so any other suggestions are welcome! Thanks in
advance! Charles
|
- RE: [flexcoders] Sleep function in ActionScript? Tracy Spratt
- Re: [flexcoders] Sleep function in ActionScript? Steve Gustafson

