Load Dynamic (constantly changing) XML Data to List in Flex
I have an XML file which changes after every one minute or precisely speaking data(nodes) in the XML are modified or added. I want to Display the simple XML data in a List which is refreshed automatically after one minute to reflect the changes. I am a newbie and i have very little knowledge about Flex so please Give me some code snippet so that i could run it and get some idea.
You can add a Timer object with the time span you need (let's say one minute) and get the XML again BUT you most probably face a caching problem where the XML contents will remain the same because the XML name didn't change.
There are 2 options for that. First, rename the XML (or add a parameter to its filename) but this option s valid only if you can administer the server or disable http caches in your code and cross your fingers to succeed because it's not always possible to persuade server with this.
A sample of what you need can be found here http://stackoverflow.com/questions/4...shot-test-code
That being said, if you did run in to that problem you can simply append the timestamp or any random characters to prevent it from being cached.
The caching will not take place on the Flash player side but on the server, that's why I said he must add some parameter to the name (as you mentioned) and in most cases it's working, but not always, as some times the application server from the other side tries to undertand the parameters, resulting in a different dataset or a 'data not found' response.
I did faced this problem twice so far. In one occasion I managed to circumvent the problem by setting url request parameters to ask from the server to not use cache (and worked), but in the other occasion server just ignored my request so I was receiving the same data again and again (that's why the cross finger suggestion lol)
You'll want to probably do the equivalent of an AJAX call via Flex. I don't have it in front of me but I think you can use the HttpRequest object.
You'll basically have your object set up to retrieve the xml with a result handler on it. Whenever you need to call it, do so:
and then you'll get your result via your handler:
private function myResultHandler(event:ResultEvent):void
//do your handling stuff here....
obviously if you using things like ArrayCollections for drop downs and such, life will be a lot easier for you.
Hope that was at all helpful,
|All times are GMT +1. The time now is 10:01 AM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.