Thanks for the huge amount of advises. ;)

As it appeared the hole thing was in method hidePopUp of PopUpWindow.
We do removePopUp there and after it focus of course changes and this
pop-up fires focusOut. in focusOutHandler we call the very same
hidePopUp. But, it isn't popped up now. So the only thing missing in
hidePopUp is test for isPopUp. The final code for hidePopUp is
following:

public function hidePopUp() : void {
    if (isPopUp) {
        PopUpManager.removePopUp(this);
    }
}

That's all.

R.

On 1/18/07, Roman Protsiuk <[EMAIL PROTECTED]> wrote:
> Yeah, and this bug appeared just recently. Is it related with Flash
> Player 9.0.28 changes or with FlexBuilder 2.0.1 hard to tell.
> Everything worked as it is without crashes before.
>
> R.
>
> On 1/18/07, Roman Protsiuk <[EMAIL PROTECTED]> wrote:
> > Hi, everyone.
> >
> > As I understand in order to properly handle focusOut event for my
> > component it should implement IFocusManagerComponent. The component I
> > develop is a pop-up window. Then strange and very unpleasant bug
> > appear. After I set focus to one of my components child and after I
> > click a button on it to close it browser crashes (firefox, ie).
> > I don't know what to say more. Here's example. Simply clicking "close
> > me" crashes browser. Totally confused.
> >
> > PopUpWindow.mxml:
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml";
> >         layout="absolute"
> >         width="400"
> >         height="300"
> >         implements="mx.managers.IFocusManagerComponent"
> >         defaultButton="{mainButton}">
> >
> >         <mx:Button id="mainButton"
> >                 horizontalCenter="0"
> >                 verticalCenter="0"
> >                 label="close me"
> >                 click="onMainButtonClick()" />
> >
> >         <mx:Button label="fake" />
> >
> >         <mx:Script>
> >                 <![CDATA[
> >                         import mx.core.UIComponent;
> >                         import mx.managers.PopUpManager;
> >
> >                         public function showPopUp(parent : UIComponent) : 
> > void {
> >                                 PopUpManager.addPopUp(this, parent);
> >                                 PopUpManager.centerPopUp(this);
> >                                 setFocus();
> >                         }
> >
> >                         public function hidePopUp() : void {
> >                                 PopUpManager.removePopUp(this);
> >                         }
> >
> >                         public override function setFocus() : void {
> >                                 super.setFocus();
> >                                 mainButton.setFocus();
> >                         }
> >
> >                         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>
> >
> >
> > popUpSample.mxml:
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> >         layout="absolute"
> >         creationComplete="onCreationComplete()">
> >
> >         <mx:Button id="clickButton"
> >                 horizontalCenter="0"
> >                 verticalCenter="0"
> >                 label="click me"
> >                 click="onButtonClick()" />
> >
> >         <mx:Button label="fake" />
> >
> >         <mx:Script>
> >                 <![CDATA[
> >                         public override function setFocus() : void {
> >                                 super.setFocus();
> >                                 clickButton.setFocus();
> >                         }
> >
> >                         private function onCreationComplete() : void {
> >                                 _popUp = new PopUpWindow();
> >                                 _popUp.addEventListener(Event.CLOSE, 
> > onPopUpClose);
> >                         }
> >
> >                         private function onButtonClick() : void {
> >                                 _popUp.showPopUp(this);
> >                         }
> >
> >                         private function onPopUpClose(event : Event) : void 
> > {
> >                                 //clickButton.setFocus();
> >                         }
> >
> >                         private var _popUp : PopUpWindow;
> >                 ]]>
> >         </mx:Script>
> >
> > </mx:Application>
> >
> > The only thought i have: it's because focus is lost (it stays in
> > pop-up) when pop-up is removed and the lost focus is unacceptable for
> > flash player. So I added clickButton.setFocus() on close. But if i do
> > it before removePopUp then PopUpWindws focusOutHandler removes it. Why
> > do i need to call it manually anyway? :/ And if i do it after calling
> > removePopUp then situation remains the same, browser crashes, not
> > surprisingly.
> >
> > Any help highly appreciated.
> > R.
> >
>

Reply via email to