Doing it on "addedToStage" event somehow doesn't work well for my 
app. My app kept on crashing due to a null popUp.

Instead of doing it on "addedToStage", I did in "removedFromStage" 
event.
This prevents the crashing problem completely.

Waiting for Flex3 HotFix.

--- In flexcoders@yahoogroups.com, Scott Melby <[EMAIL PROTECTED]> wrote:
>
> I have a PopUpButton on which I am setting a Menu as the popUp 
> property.  I have found that the popUp attribute is being nulled 
when 
> the PopUpButton is removed from the stage... which causes my button 
to 
> not function properly when added back to the stage.  I traced the 
issue 
> to the following code in PopUpButton.as which appears to be 
incorrect.  
> In this code the _popUp member (backing for the popUp setters and 
> getters) is nulled.
> 
>     private function removedFromStageHandler(event:Event):void
>     {
>         // Ensure we've unregistered ourselves from PopupManager, 
else
>         // we'll be leaked.
>         if (_popUp) {
>             PopUpManager.removePopUp(_popUp);
>             _popUp = null;
>         }
>     }
> 
> To workaround this issue I had to listen for the addedToStage event 
in 
> my view that uses this component and re-set the popUp property each 
time 
> as follows.
> 
>             /**
>              * Called each time this view is added to the stage.  
We 
> need this to work
>              * around an issue where the PopUpButton has a null 
popUp
>              * property each time it has been removed from the 
stage.
>              */
>             public function handleAddedToStage():void{
>                if(this.createButton != null && this._buttonMenu != 
null){
>                   this.createButton.popUp = _buttonMenu;
>                }
>             }
> 
> 
> Has anybody else seen this?  Can somebody please let me know if 
this is 
> a bug in the toolkit?  The workaround works fine... but seems like 
it 
> should not be necessary.
> 
> Thanks
> Scott
> 
> -- 
> Scott Melby
> Founder, Fast Lane Software LLC
> http://www.fastlanesw.com
>


Reply via email to