views:

208

answers:

3

In Flash it is possible to read XML data as the XML File loads? i.e. reading the partially downloaded XML string as the rest downloads, so we can process it as quickly as possible.

  1. Do you get an event that fires everytime small chunks of data downloads? like with URLLoader?
  2. Do you get access to the raw string since partial XML cannot be parsed?
+2  A: 

I am pretty sure you can't do this out of the box, and even if you found a way - maybe by calling a php script to load the file in chunks - I don't quite see what you would do with it as you now have a non well formed chunk of XML that you would need to try and parse gracefully. I can't imagine that would be trivial. If you really want to get you data in pieces would it be at all workable to break the file into smaller, but complete parts?

Andrew
A: 

From the Adobe Flex language reference:

Note that with a URLLoader object, it is not possible to access the data until it has been received completely.

So the answer to question 1 is that no, you cannot access data that has been only partially downloaded.

As for 2, URLLoader does not perform any form of parsing on the loaded data, you get access to raw bytes through the data attribute of the loader instance. If you know its XML, you can turn it into an XML structure with an explicit new XML(loader.data) call.

In summary, if you want partial downloads, you'll have to write your own server side solution to split up the file into smaller chunks, and download these chunks individually, as Andrew suggested.

David Hanak
+1  A: 

You could use a URLStream object to load data from a URL and read it as it downloads.

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/URLStream.html

However, you'd have to use some ad hoc SAX / Event-driven parser, since the native XML object won't work on a "partial" xml string.

Juan Pablo Califano
I was looking for an AS2 solution though.
Jenko