I guess the reason is in following line of PopUpManagerImpl.as: line 574: IUIComponent(o.owner).setVisible(true, true);
Second parameter says do not dispatch "show" event... I wonder why is it this way... Maybe someone who understands this behavior will read these lines someday. R. On 2/1/07, Roman Protsiuk <[EMAIL PROTECTED]> wrote: > Hi, everyone. > > I've modified my previous example (if anyone saw it). Now I'm using > following approach to handle pop ups: > > The pop up itself PopUpWindow.mxml: > > <?xml version="1.0" encoding="utf-8"?> > <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" > layout="vertical" > horizontalAlign="center" > width="400" > height="300" > implements="mx.managers.IFocusManagerComponent" > title="TESTING" > defaultButton="{mainButton}" > creationComplete="onCreationComplete()" > show="onShow()"> > > <mx:Box height="100%" minHeight="0" width="100%"> > <mx:Text id="traceText" text="show captured (not > creationComplete):" /> > </mx:Box> > > <mx:Canvas width="100%"> > <mx:Label id="total" text="total: none" left="10" /> > <mx:Button id="mainButton" > horizontalCenter="0" > bottom="10" > label="close me" > click="onMainButtonClick()" /> > </mx:Canvas> > > <mx:Script> > <![CDATA[ > import mx.core.Application; > import mx.managers.PopUpManager; > import mx.managers.PopUpManagerChildList; > > private static var _popUp : PopUpWindow; > > private static var _totalCounter : Number = 0; > > private static var _showCounter : Number = 0; > > public var modal : Boolean; > > public static function showPopUp(parent : > DisplayObject = null, > modal : Boolean = true) : PopUpWindow { > var popUpParent : DisplayObject = (parent != > null ? parent : > > DisplayObject(Application.application)); > > if (_popUp == null) { > _popUp = > PopUpWindow(PopUpManager.createPopUp(popUpParent, > PopUpWindow, modal, PopUpManagerChildList.APPLICATION)); > } else { > if (!_popUp.isPopUp) { > _popUp.modal = modal; > _popUp.traceText.htmlText += > (++_totalCounter).toString() + ") " > + " modality: " + modal.toString() + ". "; > > PopUpManager.addPopUp(_popUp, > popUpParent, modal, > PopUpManagerChildList.APPLICATION); > } > } > > PopUpManager.centerPopUp(_popUp); > > return _popUp; > } > > protected function hidePopUp() : void { > if (isPopUp) { > PopUpManager.removePopUp(this); > } > } > > protected function onCreationComplete() : void { > mainButton.setFocus(); > } > > protected function onShow() : void { > mainButton.setFocus(); > > traceText.htmlText += > (++_showCounter).toString() + " time" + > (_showCounter == 1 ? "" : "s"); > total.text = "total: " + > _showCounter.toString(); > } > > protected override function focusOutHandler(event : > FocusEvent) : void { > if (event.relatedObject == null || > !contains(event.relatedObject)) { > hidePopUp(); > } > super.focusOutHandler(event); > } > > private function onMainButtonClick() : void { > hidePopUp(); > dispatchEvent(new Event(Event.CLOSE)); > } > > ]]> > </mx:Script> > > </mx:TitleWindow> > > > Application popUpSample.mxml: > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > layout="absolute"> > > <mx:CheckBox id="modal" label="modal?" horizontalCenter="0" > verticalCenter="-30" /> > > <mx:Button id="clickButton" > horizontalCenter="0" > verticalCenter="0" > label="click me" > click="onButtonClick()" /> > > <mx:Script> > <![CDATA[ > private function onButtonClick() : void { > PopUpWindow.showPopUp(null, modal.selected); > } > ]]> > </mx:Script> > > </mx:Application> > > > The problem here consist in show event which should be dispatched when > component visibility is changed to true as I understand. > The bad thing is this pop up dispatches show event ONLY while it is > NOT MODAL. If I say 'let's make it modal', show event isn't > dispatched. Confusing. At least as for me. > > Can anybody explain this behavior? Or say it's not right? > > Thanks, > R. >