Eranga Perera
Eranga Perera

Reputation: 938

Is it Possible to add Minimizable Panel in flex?

Im trying to add minimizable panel in Flex. Is it possible? any ideas guys ?

Upvotes: 0

Views: 86

Answers (2)

Dave
Dave

Reputation: 596

I digged an old app I had developed in Flex 3. This was how I minimized an Application. Hope it helps!

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();
            }
        }

Upvotes: 1

Sumit
Sumit

Reputation: 729

you can take some idea from the following link:- http://flexscript.wordpress.com/2008/08/28/flex-minimize-maximize-panel-component/

Upvotes: 1

Related Questions