A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Is it possible to reload an updated, remote xml file?

  1. #1
    Senior Member
    Join Date
    Mar 2003
    Location
    wishconsin
    Posts
    151

    Question Is it possible to reload an updated, remote xml file?

    This seem like a silly question but as far as I've found: It's impossible to reload an xml file from a remote location while the SWF is running.

    Is this true?

    For example, I have a kiosk project that will run 24/7 (with a restart each night). I have an "calendar events" loading off an XML file that I want to keep on a webserver so I can update the kiosk by editing the XML file. However, the SWF caches the first XML file and keeps reusing it. I'm testing this by triggering a function that reloads the XML file with a button click.

    I found trick that concats a unique ID to the file name which prevents using the old file but that means I'll have an ever growing list of XML files in the Temporary Internet Files folder.

    So please, if there is another way to do this, I would like to know.

    Thanks in advance.

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Using the unique id is the usual way of doing it. What do you mean with Temporary Internet Files folder? This memory is only by users as long as they stay on your site. The unique id only affects browser cache.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Member
    Join Date
    Feb 2007
    Posts
    63
    A few things come to mind - what process are you following to bring in your xml?

    I was always under the impression every time you use your loader variable to load in an xml file, it reconnects and downloads the data no matter what.

    I never tried this, so it sounds like it's not the case. You might want to try remoting to a php script that will pull this data in and feed it to you via xml. This would allow for a bit more control, as php is able to pull in whatever data is in the file, whether or not its the same file name.

    Also, you might want to check the web server that everything is hosted has a server caching issue where it may not want to update the actual xml data once it's dynamically created.

  4. #4
    Member
    Join Date
    Feb 2007
    Posts
    63
    Sorry. I clicked once, but it posted twice.

  5. #5
    Senior Member
    Join Date
    Mar 2003
    Location
    wishconsin
    Posts
    151
    Quote Originally Posted by biscuitcleaver View Post
    A few things come to mind - what process are you following to bring in your xml?

    I was always under the impression every time you use your loader variable to load in an xml file, it reconnects and downloads the data no matter what.

    I never tried this, so it sounds like it's not the case. You might want to try remoting to a php script that will pull this data in and feed it to you via xml. This would allow for a bit more control, as php is able to pull in whatever data is in the file, whether or not its the same file name.

    Also, you might want to check the web server that everything is hosted has a server caching issue where it may not want to update the actual xml data once it's dynamically created.
    Interesting thoughts. Here's what I'm doing in my 'download' function:

    Code:
    private function downloadData():void
    		{
    			var myID:String = String(Math.round(Math.random()*10000));
    
    			var xmlString:URLRequest=new URLRequest("http://www.myurl.com/dev/events.xml?uniq="+myID);
    
    			var xmlLoader:URLLoader=new URLLoader(xmlString);
    			xmlLoader.addEventListener("complete", readXML);
    		}

  6. #6
    Member
    Join Date
    Feb 2007
    Posts
    63
    That should work - as long as your random number is actually able to pull in an xml document.

    Try tracing the result. Is it still pulling the same xml?

  7. #7
    Senior Member
    Join Date
    Mar 2003
    Location
    wishconsin
    Posts
    151
    Quote Originally Posted by biscuitcleaver View Post
    That should work - as long as your random number is actually able to pull in an xml document.

    Try tracing the result. Is it still pulling the same xml?
    If im using the above function, no, it never pulls in the same content, assuming its been changed. But if I don't use the uniq value, it just reuses the same xml over and over again.

  8. #8
    Member
    Join Date
    Feb 2007
    Posts
    63
    Yeah, I'm a bit embarrassed, I forgot that you got it to work with the naming system - but you're looking for something a bit more eloquent. Sorry.

    I had a thought though. Are you performing some sort of garbage collecting? When you pull in the xml, are you making sure the variable it's being loaded into is nullified?

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center