FORUMS: list search recent posts

reload XML file within projector

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Rob Jackson
reload XML file within projector
on Jul 15, 2010 at 4:09:44 pm

I have a Flash projector running digital signage. It loads the XML, with a cache buster set up so every time the .exe is launched, it reloads the XML file. What I need it to do is reload the XML file without exiting the projector. For instance, every 10 minutes or, preferably, at 5pm I want it to reload the XML file. It's a digital sign so I don't want to just tell Windows to schedule a task to close and reopen the .exe file.

Anyone have suggestions on where to start? My AS3 code is over 800 lines, so I'm not going to post it here, but here are some key lines:

try {

var flashvars :Object = Object(LoaderInfo(this.loaderInfo).parameters);
xmlsource = String(flashvars["XMLSource"]);

catch(error:IOErrorEvent) {
trace("IOErrorEvent catch: " + error);

} catch(error:TypeError) {
trace("TypeError catch: " + error);

} catch(error:Error) {
trace("Error catch: " + error);

} finally {

if (xmlsource == "undefined") {xmlsource = ""+Math.floor(Math.random()*999)}


xmlloader.load(new URLRequest(xmlsource));
xmlloader.addEventListener(Event.COMPLETE, parseXML);

Return to posts index

Rob Jackson
Re: reload XML file within projector
on Jul 16, 2010 at 11:15:38 pm

Hi Mike, thanks for the response!

I have tried a couple different placements of setInterval, but haven't gotten it to successfully work. I guess I'm having a problem placing it correctly. If I set the xmlloader lines inside a function with setInterval around it, it stops looking at the xml file and puts up a red screen at the correct interval time. No errors appear in the output window, but my trace information does. The projector continues to run, showing the trace at the correct intervals. I haven't tried a timer object yet. I will try that next.

I'm wondering if it's because the xml file isn't being loaded in a function that I'm running into this issue. This isn't my code, I was handed it by another programmer and asked to find a way to do this particular function. The xml file is used in a function further down the code sheet so that the slides it is calling will loop. Perhaps I need to throw code in where it tells the exe to check the slide number and if the next slide equals 0 it should repeat? Maybe when that slide is reached I need code to tell it to reload the xml file? I just need it to clear out the old data first.

I don't have access to the file again until Sunday, so I can't post any specific code until then. Do you, or anyone else reading this, have any suggestions either on placement of setInterval or for a different tactic?

Return to posts index

Mike Smith
Re: reload XML file within projector
on Jul 17, 2010 at 11:38:31 am

Wouldn't you want to put your xml loader and associated actions into a named function, then call that function by name so that it runs, then have setInterval call the named function an appropriate time delay ..?

Return to posts index

Rob Jackson
Re: reload XML file within projector
on Jul 18, 2010 at 4:21:47 pm

I'm new to AS so if I've screwed this up, please feel free to heckle.

So what I tried was create:

var reloadInterval = setInterval(loadXML, 20000);

Then created

function loadXML():void
xmlloader.load(new URLRequest(xmlsource))
xmlloader.addEventListener(Event.COMPLETE, parseXML);

The result was correctly running the function every 20 seconds, however after the first successful load (it didn't load for the first 20 seconds as I hadn't written that in yet), when it called the function again, the screen went red, no slides. No error displayed in the output window. This is both in the Flash test movie and as a published file.

I've uploaded the whole Flash CS4 file in case anyone wants to take a look at it. The loop commands are around line 557.

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved