SysToast: A System Tray Notifier for AIR Applications
EverythingFlex has an excellent SysTray notification class called NativeAlertWindow. What it does is create a ‘toast’ window in the bottom right corner of your screen. When an event happens, a window will pop up, literally like toast, on your screen next to the system tray. This is very similar to what MSN Messenger, Norton, McAfee, and countless other programs do.
The problem with NativeAlertWindow is it is part of a SWC (a precompiled Flash file that is not editable) called everythingflexairlib. So you aren’t able to look at the code or change things easily if you need to. This is a very basic replica of NativeAlertWindow but not compiled in a SWC. It will get you started on creating toast windows. Extending it is up to you.
Copy the SysToast class file to the appropriate location in your project. The following is all that is needed in your MXML file.
import net.sanative.SysToast;
public function callToast():void
{
var mytoast:SysToast = new SysToast("mymessage", "mytitle", mydelay,
mywidth, myheight, mylifetime, "mychrome", "mytype", mygap);
}
That is all that is needed to create a toast window. The ‘my’ variables would be replaced with actual values according to your application.
- mymessage (Required) (String) - Message to display in the toast window. Default is null.
- mytitle (String) - Text to display in the title of the toast window. Default is 'Alert'.
- mydelay (Number) - Amount of delay between the time the toast was called until it is created. This is a millisecond number value. 1000 = 1 second. Default is 0.
- mywidth (Number) - Width of the toast window. This is a pixel number value. Default is 200.
- myheight (Number) - Height of the toast window. This is a pixel number value. Default is 100.
- mylifetime (Number) - Time that the toast window will be visible for. This is a millisecond number value. 1000 = 1 second. Default is 8000.
- mychrome (String) - System chrome to use for the toast window. Possible values are 'none' and 'standard'. Default is 'standard'.
- mytype (String) - Type of window the toast window will be considered. Possible values are 'lightweight', 'normal', and 'utility'. NOTE: 'lightweight' ONLY works with 'none'. Default is 'normal'.
- mygap (Number) - Gap between the bottom and right side of the screen to position the toast window. This is a pixel number value. Default is 10.
As I stated before, this is a very basic class. We will update the class over time to eliminate some of the limiations and make it full-featured. That being said here are the current limitations:
- This is not a toast window manager. This means that it can only show one toast window at a time for each variable reference.
- Each toast window created is placed in the bottom right corner.
- It does not apply stacking for better viewing.
- There are no transition in or out effects. Windows Vista has its own native window open and close effect which fakes a transition effect for me in the mean time.
- Toast windows cannot be minimized, maximized, or resized. More than likely this will not change. Allowing those defeats the purpose of a toast window.
- Icons and/or images are not utilized in the titlebar or on the toast itself.
- The style of the text cannot be changed with CSS unless it is changed in the class itself.
If you have recommendations or suggestions please feel free to drop us an email!
SysToast Files
0 comments - Posted by David Freerksen at 3:23 PM - Categories: Adobe AIR
