Search code examples
actionscript-3airflash-cs5

Need my Adobe Air desktop App to make the system tray icon blink


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


Solution

  • 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);