2 Replies Latest reply on Nov 23, 2009 8:42 PM by vrn_shan

    Sometimes Tray Icon not loaded correctly

    vrn_shan Level 1

      I am trying to make my (html/ajax) website available as a desktop application, (with little enhancements like notifications in the background etc.)  without writing any extra code. Everything works fine except the tray icon. Sometimes the tray icon is not loading correctly.


      Following is the structure of my sample air application.


      1. An html page(page1.html) i am using as my inital window.

      It creates an invisible html window and loads a new page (page2.html) as below.


              var options = new air.NativeWindowInitOptions();

              options.systemChrome = "standard";

              var windowBounds = new air.Rectangle(200,250,300,400);

              newHTMLLoader = air.HTMLLoader.createRootWindow(false, options, false, windowBounds);

              newHTMLLoader.window.mainAppWindow = window;

              newHTMLLoader.load(new air.URLRequest("page2.html"));


      and later redirecting to the website.



      2. I am using this invisible html window to control the application behavior (like sending ajax requests in the background, monitoring network, checking for updates etc.)

      page2.html contains code to load the tray icon for the application.


      Here is javascript the code in page2.html


      function BgWindow(){

              this.init = function(){




              var iconLoadComplete = function(event){

                  air.NativeApplication.nativeApplication.icon.bitmaps = [event.target.content.bitmapData];



              this.loadTrayIcon = function() {

                  air.NativeApplication.nativeApplication.autoExit = true;

                  var iconLoad = new air.Loader();


                  if (air.NativeApplication.supportsSystemTrayIcon) {


                      iconLoad.load(new air.URLRequest("lmt16.png"));





          window.onload = function(){

              bgWindow = new BgWindow();




      But the problem here is, sometimes the icon is loaded correctly but sometimes its not loaded.

      What am I missing here ?

      Any help is appreciated.


      I am attaching the complete application if somebody needs to analyze it.