next up previous contents
Next: Downloading and uploading files Up: Tutorials Previous: Accessing databases   Contents

Programming the tray icons

If you check the "Show in the system tray" option in "Application definitions" panel, the output .exe file will display a tray icon. However, the function of the tray icon is too simple. If you want to fully customized the tray icon for your applications, please use the "Application.SysTray" object. In this tutorial, we will discuss how to customize tray icons in action script in Flash 8.

First, we would have to disable the default tray icon behavior of SWFKit:

    import SWFKit.*;
    import SWFKit.application.*;

    SysTray.useDefaultHandler = false;

Second, add an icon into the system tray area. The icon file is loaded from the resources list

    SysTray.icon = Global.getAdditionalFile("NET01.ICO");
    SysTray.tip = 'A test';
    SysTray.add();

Finally, add event handler for the tray icon

    function onRClicked()
    {
        var menu = new Menu;
        menu.createPopupMenu();
        menu.appendItem("id0", "item 0");
        menu.appendItem("id1", "item 1");
        menu.appendItem();
        menu.appendItem("id2", "item 2");
        menu.appendItem("id3", "item 3");

        Global.getMainWnd().bringToTop();
        var id = menu.show();
        Dialogs.msgBox(id);
    }

    function onLClicked()
    {
        SysTray.balloonTip = "Happy New Year!";
        SysTray.balloonTitle = "Hello";
        SysTray.balloonIcon = "warning";
        SysTray.showBalloonTip();
    }

    var st = new SysTray;
    st.setEventHandler("onRClicked", onRClicked);
    st.setEventHandler("onLClicked", onLClicked);



Copyright ©2000-2010 Shanghai TopCMM Software Technologies. All Rights Reserved.