0

I have a created in Flash CS5 a very simple Adobe Air Desktop App. The App is just a small 400 x 200 window that has a dynamic text field that loads a ".txt" file sitting out on the internet using URLRequest. The App checks for a new file at set intervals, right now every 5 minutes.

I need to find a way to make the App blink the system tray icon or Flash a button in the Application itself when a "NEW" file has been loaded looking at the time/date stamp of the ".txt" file. not just when it loads the file again.

I apologize in advance I am very new to Adobe Air and Flash Actionscript 3.0

1 Answers1

0

For desktop (not mobile) AIR apps, you could use the NativeWindow class's nofityUser function.

Example:

import flash.desktop.NotificationType;
import flash.events.MouseEvent;

function notifyMe(aNotificationType:String):void
{
    if(NativeWindow.supportsNotification)
    {
        stage.nativeWindow.notifyUser(aNotificationType);
    }
    else
    {
        trace("Notification not supported on this OS");
    }
}

function onStageClicked(e:MouseEvent):void
{
    // You could also pass NotificationType.CRITICAL here
    notifyMe(NotificationType.INFORMATIONAL);
}
stage.addEventListener(MouseEvent.CLICK, onStageClicked);
T Graham
  • 1,329
  • 10
  • 14
  • its not a mouse event I am looking for :) its when the ".txt" file is updated. – Brian Haugen Jan 15 '13 at 02:43
  • Could I do something with the URLRequest. have it set to use theCache unless file has been modified then notify App or Sytem tray icon. – Brian Haugen Jan 15 '13 at 02:44
  • var loader:URLLoader = new URLLoader(new URLRequest("https://my_text_file.txt")); loader.addEventListener(Event.COMPLETE, completeHandler); Appfunction completeHandler(event:Event):void { var loadedText:URLLoader = URLLoader(event.target); myText_txt.htmlText = loadedText.data; } This what I have now to load txt file – Brian Haugen Jan 15 '13 at 02:55
  • I used a MouseEvent to keep the example simple – any event could have called the notifyMe() function. In the code you've put in the comment, you could call notifyMe() from completeHandler(). – T Graham Jan 15 '13 at 03:09
  • One more question :) I got the App to notify when file is loaded. but now it is notifying every time it loads the file. It checks for a new file every five minute or whatever I have the timer set at. Is there a way to notify only if the file is new? by the files timestamp or something – Brian Haugen Jan 15 '13 at 14:17
  • That can be done, but you should probably ask a separate question about that. Also, you're more likely to get a response to other questions if you mark a good response as "accepted." – T Graham Jan 15 '13 at 16:11
  • I will do that, I am new to this site and don't know how to mark a response as accepted :) thanks again – Brian Haugen Jan 15 '13 at 16:24
  • No problem (I didn't mean it as a criticism). It's common for people who are new to the site to ask questions and then never accept an answer. As a result, their newer questions tend to be ignored. Reputation points are the currency of this site, and accepting an answer is like tipping a waiter/waitress :-) Anyway, to accept a correct/helpful answer, just click the check mark button on the left side of an answer. The check mark buttons only appears within questions you ask, not questions from other people. See http://stackoverflow.com/faq#howtoask for more information. – T Graham Jan 15 '13 at 17:17