Saturday, October 17, 2009

How to create a floating window (dialog, panel) in the ESRI Sample flexviewer?

How to create a floating window (dialog, panel) in the flexviewer?

There are many scenarios when you'd like to have a new window open from an action triggered from inside a widget or the InfoPopup. This is one way to do it.
1) Create you custom component, e.g. TitleWindow, Panel, or create a draggable panel
2) Add properties/methods to that component
3) Use PopupManager to create/re-use that component to show information from the widget


//Widget Code
private var myPopup:MyCustomComponent=null;

private function onButtonClick(infoData:Object):void {
 if (this.myPopup) {
    PopupManager.centerPopup(myPopup);
    PopupManager.bringToFront(myPopup); 
 } else {
    this.myPopup = new MyCustomComponent();
    PopupManager.addPopup(myPopup, this, false);
    PopupManager.centerPopup(myPopup);
    PopupManager.bringToFront(myPopup); 
 }
 //change properties of myPopup
 myPopup.title = "Details for " + infoData.title;
 myPopup.featureId = infoData.featureId;
 myPopup.fetchFeatureDetails();
}

No comments:

Post a Comment