0 Replies Latest reply on Dec 9, 2009 12:59 PM by sagiep

    Opening a window from a taskbar icon lags application!! PLZ HELP!

    sagiep

      Hey, everyone!

      I'm trying to have an application icon in my taskbar, that once I click on it, will open a new window.

      That's pretty simple to do, so i thought, but then I came across something wierd!!

       

      When I open the window with the click on the icon, the entire application (all other windows too) really lag!!

      And there is no increase in CPU or MEM usage, or anything!

      If you close the windows, the application still lags once you open a new one.

      And the wierdest thing is, that if you open the window with a right-click, and clicking on the menu item which shows up, no lagging is caused whatsoever!

       

      I should note that this only happens when the window contains the RichTextEditor component. Maybe it's a specific problem with the component, or maybe it's a general performance issue, and the RichTextEditor is just really 'heavy'. I dunno....

       

      Anyways, here is the code. Hope you guys can help!!!

       

      EditorWindow.mxml

      <?xml version="1.0" encoding="utf-8"?>
      <s:Window xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" 
                   xmlns:mx="library://ns.adobe.com/flex/halo" width="400" height="300">
           <mx:RichTextEditor/>
      </s:Window>
      

       

      App.mxml

      <?xml version="1.0" encoding="utf-8"?>
      <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                  xmlns:s="library://ns.adobe.com/flex/spark" 
                                  xmlns:mx="library://ns.adobe.com/flex/halo" xmlns:local="*"
                                  creationComplete="initIcon();" applicationComplete="close()">
           <fx:Script>
                <![CDATA[
                     import flash.display.NativeMenu;
                     import flash.display.NativeMenuItem;
                     import flash.events.Event;
                     import flash.events.MouseEvent;
                     import flash.net.URLRequest;
                     
                     private function initIcon():void
                     {
                          var icon:Loader = new Loader();
                          var iconMenu:NativeMenu = new NativeMenu();
                          iconMenu.addItem(new NativeMenuItem("New")).addEventListener(Event.SELECT, onClickHandler);
                          
                          if (NativeApplication.supportsSystemTrayIcon) 
                          { 
                               NativeApplication.nativeApplication.autoExit = false; 
                               icon.contentLoaderInfo.addEventListener(Event.COMPLETE, iconLoadComplete); 
                               icon.load(new URLRequest("icon.gif"));
                               
                               var systray:SystemTrayIcon =  
                                    NativeApplication.nativeApplication.icon as SystemTrayIcon;
                               systray.addEventListener(ScreenMouseEvent.CLICK, onClickHandler);
                               systray.menu = iconMenu; 
                          } 
                     }
      
                     private function iconLoadComplete(event:Event):void 
                     { 
                          NativeApplication.nativeApplication.icon.bitmaps = 
                               [event.target.content.bitmapData];
                     } 
                     
                     private function onClickHandler(event:Event):void
                     {
                          new EditorWindow().open();
                     }
                ]]>
           </fx:Script>
      </s:WindowedApplication>
      

       

      Thanks in advance to anybody who read this post (: