You can always just move the Alert yourself...

 private function popUpAlert():void{

                var myMenu:Menu = new Menu();
                var popUpButton:PopUpButton = new PopUpButton();
                 addChild(popUpButton);
                 popUpButton.x = this.width / 2;
                 popUpButton.y = this.height / 2;

                var dp:Object = [{label: "Alpha"}, {label: "Beta"}, {label:
"Gamma"}];
                myMenu.dataProvider = dp;
                myMenu.selectedIndex = 0;
                myMenu.addEventListener("itemClick", itemClickHandler);
                popUpButton.popUp = myMenu;
            }

            private function itemClickHandler(evt:MenuEvent):void{

                var alert:Alert = Alert.show("Are you sure? \n\n There is no
Un-Do",
                            'Delete *All Completed* ?',
                            Alert.YES| Alert.NO,
                            null,
                            responseToDeleteAllCompletedHandler,
                            null,
                            Alert.NO);

                alert.move (parentDocument.width / 2 - alert.width/2,
parentDocument.height /2 - alert.height / 2);
            }

            private function
responseToDeleteAllCompletedHandler(evt:CloseEvent):void{

                if(evt.detail == Alert.YES)
                    trace("Yes");
                else
                    trace("No");
            }

On Thu, Nov 12, 2009 at 4:26 PM, steveb805 <[email protected]>wrote:

>
>
> Seems like until now, my Alert boxes appear in the center ok.
>
> However, now that I am using a PopUpButton, and in response to one of the
> menu item clicks I am calling Alert.show(), the popup box is stuck at the
> upper left.
>
> My popupbutton handler:
>
> private function itemClickHandler(event:MenuEvent):void {
> switch (event.index) {
> case 0:
> ...
> case 1:
> Alert.show( "Are you sure? \n\n There is no Un-Do",
> 'Delete *All Completed* ?',
> Alert.YES| Alert.NO,
> null,
> responseToDeleteAllCompletedHandler,
> null,
> Alert.NO);
> default:
> }
> }
>
> For the parent parameter - which is supposed to be a Sprite - I tried
> this.parent, hoping this would fix it, but complained of type mismatch.
>
> Weird that the Alert works fine when calling it in response to normal
> buttons on my main panel, but all of a sudden the Alert is confused about
> the parent when calling the Alert.show in response to a *popup* type button.
>
> ( maybe I should download an updated Flex sdk? it's been a couple of
> months)
>
> Any advice would help
> tx,
> Steve
>
>  
>

Reply via email to