是否可以在flex中添加Minimizable Panel?

时间:2013-11-18 08:01:48

标签: actionscript-3 flex flex4 flex3 flex4.5

我试图在Flex中添加最小化面板。可能吗?任何想法的家伙?

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:1)

我挖掘了我在Flex 3中开发的旧应用程序。这就是我最小化应用程序的方式。 希望它有所帮助!

private var trayIcon:BitmapData;

//onCreation of App
public function initApp(event:Event):void
{
    loadTrayIcon();
    this.addEventListener(Event.CLOSING, minToTray);
}

private function minToTray(event:Event):void{
    event.preventDefault();
    dock();
}

public function loadTrayIcon():void
{
    var loader:Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, readyToTray);
    loader.load(new URLRequest("assets/circleblack.PNG"));
}

public function dock():void{
        stage.nativeWindow.visible = false;
    NativeApplication.nativeApplication.icon.bitmaps = [trayIcon];
}
   private function closeApp(event:Event):void{
    stage.nativeWindow.close();
}

   public function unDock(event:Event):void{
    stage.nativeWindow.visible = true;
    stage.nativeWindow.orderToFront();
    NativeApplication.nativeApplication.icon.bitmaps = [];
}

   public function readyToTray(event:Event):void{
            trayIcon = event.target.content.bitmapData;

            var myMenu:NativeMenu = new NativeMenu();

            var openItem:NativeMenuItem = new NativeMenuItem("Open");
            var closeItem:NativeMenuItem = new NativeMenuItem("Close");

            openItem.addEventListener(Event.SELECT, unDock);
            closeItem.addEventListener(Event.SELECT, closeApp);

            myMenu.addItem(openItem);
            myMenu.addItem(new NativeMenuItem("", true));
            myMenu.addItem(closeItem);

            this.systemTrayIconMenu 
            if(NativeApplication.supportsSystemTrayIcon){
                           SystemTrayIcon(NativeApplication.nativeApplication.icon).tooltip = "Test App";

                SystemTrayIcon(NativeApplication.nativeApplication.icon).
                    addEventListener(MouseEvent.CLICK, unDock);

                stage.nativeWindow.addEventListener(
                    NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING, winMinimized);

                SystemTrayIcon(NativeApplication.nativeApplication.icon).menu = myMenu;
                this.nativeApplication.menu = myMenu;
            }
        }

        private function winMinimized(displayStateEvent:NativeWindowDisplayStateEvent):void{
            if(displayStateEvent.afterDisplayState == NativeWindowDisplayState.MINIMIZED){
                displayStateEvent.preventDefault();
                dock();
            }
        }