0

using AS3 and Flash CS5

I have a messageboard Adobe Air desktop App with a URLLoader making a URLRequest for a ".txt" file every 2 minutes. or however long I set the time to look. The App loads the txt file into a dynamic text field.

var loader:URLLoader = new URLLoader(new URLRequest("https://my_text_file.txt"));
loader.addEventListener(Event.COMPLETE, completeHandler);

function completeHandler(event:Event):void {
    var loadedText:URLLoader = URLLoader(event.target);
    myText_txt.htmlText = loadedText.data;
}

Is it possible to have the URLRequest load the file only if its new? not every time?

then when the "new" file has been loaded fire

mainWindow.notifyUser(NotificationType.CRITICAL) 

so the user knows there is a new message?

thanks in advance!!

2 Answers2

1
var loader:URLLoader = new URLLoader(new URLRequest("https://my_text_file.txt"));
loader.addEventListener(Event.COMPLETE, completeHandler);

function completeHandler(event:Event):void {
    var loadedText:URLLoader = URLLoader(event.target);
    if(myText_txt.htmlText!=loadedText.data){
        myText_txt.htmlText = loadedText.data;
            mainWindow.notifyUser(NotificationType.CRITICAL) 
    }else {
        //do nothing
    }
}
The_asMan
  • 6,364
  • 4
  • 23
  • 34
  • thanks for the quick response. when I publish file I get an error - Scene 1, Layer 'as text', Frame 1, Line 15 1120: Access of undefined property mainWindow. – Brian Haugen Jan 15 '13 at 17:28
0

Since the application will still be running you should just compare the old text file to the new one to see if there have been any changes made.

Tim Lieberman
  • 571
  • 2
  • 5
  • 23