Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    May 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    New Coder djpaul1963's Avatar
    Join Date
    Apr 2012
    Location
    Athens GR
    Posts
    74
    Thanks
    0
    Thanked 8 Times in 8 Posts
    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

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    Quote Originally Posted by djpaul1963 View Post
    BUT you most probably face a caching problem where the XML contents will remain the same because the XML name didn't change.
    I don't think caching would be an issue(I have a similar process and I haven't seen it come up yet), because the Flash player isn't going to be wasting memory on caching unused data since it uses so much memory already. I could be wrong though in that assumption and it simply hasn't been a problem yet.

    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.

  • #4
    New Coder djpaul1963's Avatar
    Join Date
    Apr 2012
    Location
    Athens GR
    Posts
    74
    Thanks
    0
    Thanked 8 Times in 8 Posts
    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)
    Last edited by djpaul1963; 06-01-2012 at 04:12 PM.

  • #5
    New to the CF scene
    Join Date
    Aug 2012
    Location
    India
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi there,

    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:

    ActionScript Code:
    myService.send();
    and then you'll get your result via your handler:

    ActionScript Code:
    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,


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •