8 Replies Latest reply on Jul 26, 2010 2:19 AM by speedy82

    Support system tray icon of Air application

    speedy82

      Hi All,

      I developed a widget with flash builder 4 and I exported all the project in AIR application. Then, I packaged AIR application in .exe file for Windows, and dmg file for MAC. My application works correctly for both of OS.

      When I launch application on OS Windows, an image on system tray (for my application a socceer ball) appears. On the other side, on OS MAC my icon appears, but after 3 or 4 seconds it disappears and it is replaced with an other icon (probably it's a default icon of mac for this kind of application?) ...

      What can I do? Thanks in advance, regards

       

      Gianni

        • 1. Re: Support system tray icon of Air application
          thilgen Level 4

          What does the icon that replaces your icon look like?

           

          Can you attach a screenshot to forum post?

           

          Also, can you get the problem to occur with a regular AIR application?

           

          Or does this only happen for AIR aplications that are packaged as DMG files?

           

          Thanks,

           

          Chris Thilgen

          AIR Engineering

          • 2. Re: Support system tray icon of Air application
            speedy82 Level 1

            I've attached a screenshot of icon .

            My AIR application works with Windows OS .In fact after launching 

            application, icon named" soccerBall.png" appears on system tray.

            On MAC this icon is replaced by "icon.png" after about 2-3 seconds launching

            application.

            This problem occurs only with dmg file!

            Thanks,

            Gianni

             

             

             

             

            >--Messaggio originale--

            >Da: forums@adobe.com

            >Data: 20/07/2010 20.23

            >A: "gianni bandi"<rock70@libero.it>

            >Ogg: Support system tray icon of Air application

            >

            >What does the icon that replaces your icon look like?

            >Can you attach a screenshot to forum post?

            >Also, can you get the problem to occur with a regular AIR application?

            >Or does this only happen for AIR aplications that are packaged as DMG files?

            >Thanks,

            >Chris Thilgen

            >AIR Engineering

            >

            • 3. Re: Support system tray icon of Air application
              speedy82 Level 1

              Hi All,

              I remind you that I'll appreciate every kind of suggestion from you to solve

              my problem...

               

              do you have an idea ... In your opinion why does dmg file work in this way?

              Thanks

               

              Gianni

              • 4. Re: Support system tray icon of Air application
                thilgen Level 4

                I don't see the screenshot attachment...

                • 5. Re: Support system tray icon of Air application
                  speedy82 Level 1

                  icon.png

                  soccerBall.png

                  Sorry,

                  Here there are images ....

                   

                  Gianni

                  • 6. Re: Support system tray icon of Air application
                    thilgen Level 4

                    I am a little confused - is this a system tray icon or a task bar icon?

                     

                    In other words - is this icon somehting you are setting as part of your app descriptor or are you taking advantage of the SystemTrayIcon and DockIcon APIs in AIR?

                     

                    Providing a sample for me to look at would be super-helpful.

                     

                    Can you take your app and just carve out anything not having to do with the icons and attach it here so I can take a look?

                     

                    Thanks,

                     

                    Chris Thilgen

                    AIR Engineering

                    • 7. Re: Support system tray icon of Air application
                      thilgen Level 4

                      I just made a small sample application that sets the dock icon on mac using the DockIcon class when I press a button in the main application window.

                       

                      Seems to work the same as both an AIR file and as a DMG using the AIR 2.0 runtime.

                       

                      Seeing your application code would probably be best at this point.

                       

                      Thanks,

                       

                      Chris Thilgen

                      AIR Engineering

                      • 8. Re: Support system tray icon of Air application
                        speedy82 Level 1

                        I attached files reporting images of icon on system tray. I didn't set any option on app descriptor, I used SystemTrayIcon and DockIcon APIs.
                        Anyway I attach part of my application code ...
                        windowComplete event of WindowedApplication is handled by function preInit () ...

                         

                                    private function onWindowActivate():void
                                    {
                                        if (!this.windowActivateRequest)
                                        {
                                            this.dock();
                                        }
                                    }
                                   
                                    private function onInvoke( event:InvokeEvent ):void
                                    {
                                        if( event.reason == InvokeEventReason.LOGIN )
                                        {
                                            //do background processing...
                                            trace( "Running in background..." );
                                            this.windowActivateRequest = false;
                                            this.dock();                   
                                        }            
                                        else
                                        {
                                            trace("Running on screen");
                                            this.windowActivateRequest = true;
                                            if (this.stage != null)
                                            {
                                                this.stage.nativeWindow.activate();   
                                            }
                                        }
                                    }
                                   
                                    public function dock(event:Event = null):void
                                    {
                                        stage.nativeWindow.visible = false;
                                       
                                        var imgObj:BitmapAsset = new trayIcon() as BitmapAsset;
                                        var bitmampDataTmp:BitmapData = imgObj.bitmapData;
                                        var arrayTmp:Array = new Array();
                                        arrayTmp.push(bitmampDataTmp);
                                        
                                        NativeApplication.nativeApplication.icon.bitmaps = arrayTmp;
                                    }
                                   
                                    public function undock(event:Event = null):void
                                    {
                                        this.windowActivateRequest = true;
                                        stage.nativeWindow.visible = true;
                                       
                                        NativeApplication.nativeApplication.icon.bitmaps = [];
                                    }
                                   
                                    private function preInit():void
                                    {
                                        try
                                        {
                                            NativeApplication.nativeApplication.startAtLogin = true;
                                        }
                                        catch ( e:Error )
                                        {
                                            trace( "Cannot set startAtLogin:" + e.message );
                                        }
                                       
                                        NativeApplication.nativeApplication.addEventListener( InvokeEvent.INVOKE, onInvoke );
                                       
                                        if(NativeApplication.supportsDockIcon)
                                        {
                                            var dockIcon:DockIcon = NativeApplication.nativeApplication.icon as DockIcon;
                                            NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE,undock);
                                            dockIcon.menu = createIconMenu();
                                        }else{
                                            if (NativeApplication.supportsSystemTrayIcon){
                                                var sysTrayIcon:SystemTrayIcon = NativeApplication.nativeApplication.icon as SystemTrayIcon;
                                                sysTrayIcon.tooltip = "Stopwatch";
                                                sysTrayIcon.addEventListener(MouseEvent.CLICK,undock);
                                                sysTrayIcon.menu = createIconMenu();   
                                            }                   
                                        }
                                    }
                                   
                                    private function createIconMenu():NativeMenu
                                    {
                                        var iconMenu:NativeMenu = new NativeMenu();
                                        var exitCommand: NativeMenuItem = iconMenu.addItem(new NativeMenuItem("Esci"));
                                        exitCommand.addEventListener(Event.SELECT, chiudi);
                                       
                                        return iconMenu;
                                    }

                         

                        trayIcon is name of .png which represent ball image ...  

                        I try to summarize ...In MAC OS DockIcon isn' t represented by ball image ...In Windows OS everything works.

                         

                        I'm sorry for disturbing you but I hope that everything is clear.

                        Thanks