Mark-

I don't know what you did to test this, but I was not guessing at my 
answer.  This is something I actually use (FB 4.6, btw, in case that 
matters).  As my gift to you, here is my simple Alert component that 
extends s:SkinnablePopUpContainer (attached as a ZIP and also pasted 
into the message, since I don't know which will work best on the list).

As you can see, it calls PopUpManager.centerPopUp(this) when it is first 
added to the stage and also anytime it receives a Resize event while it 
is open.  Some of the component is borrowed from tutorials I've seen on 
the web, but the code to handle resizing and centering was my own work.

-Jeff

<?xml version="1.0" encoding="utf-8"?>
<s:SkinnablePopUpContainer
     xmlns:fx="http://ns.adobe.com/mxml/2009";
     xmlns:s="library://ns.adobe.com/flex/spark"
     addedToStage="_QueueCenter()"
     creationComplete="_Init()"
 >
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
             import mx.core.FlexGlobals;
             import mx.managers.PopUpManager;

             import spark.components.supportClasses.ViewNavigatorAction;

             [Bindable]
             public var alertTitle:String = "alertTitle";

             [Bindable]
             public var alertMessage:String = "alertMessage";

             private var _appTop:Object = 
mx.core.FlexGlobals.topLevelApplication;

             [Bindable]
             private var _nMaxWidth:Number = 300;

             private function _Center ( ) : void
             {
                 if ( isOpen ) PopUpManager.centerPopUp ( this );
             }

             private function _Init ( ) : void
             {
                 _appTop.addEventListener ( Event.RESIZE, _Resize );
             }

             private function _Resize ( e:* = null ) : void
             {
                 if ( isOpen ) _QueueCenter ( );
             }

             private function _QueueCenter ( ) : void
             {
                 _nMaxWidth = 0.9 * Math.min ( _appTop.width, 
_appTop.height );
                 callLater ( _Center );
             }

         ]]>
</fx:Script>
<s:TitleWindow
         id="titleWindow"
         title="{alertTitle}"
         maxWidth="{_nMaxWidth}"
         close="close()"
 >
<s:VGroup
             horizontalAlign="center"
             horizontalCenter="0"
             paddingLeft="16"
             paddingTop="16"
             paddingRight="16"
             paddingBottom="16"
             gap="24"
             width="100%"
 >
<s:Label
                 id="message"
                 text="{alertMessage}"
                 width="100%"
                 />
<s:Button
                 label="OK"
                 click="close(true)"
                 />
</s:VGroup>
</s:TitleWindow>
</s:SkinnablePopUpContainer>

On 2/19/2012 08:15, markflex2007 wrote:
> I just test.PopUpManager can not work with s:SkinnablePopUpContainer.
>
> other idea?
>
> Thanks
>
> Mark
> --- In flexcoders@yahoogroups.com, Jeff Gomes<jgomes@...>  wrote:
>> PopUpManager.centerPopUp(pop);
>>
>> On 2/17/2012 14:36, markflex2007 wrote:
>>> Hi
>>>
>>>    I use<s:SkinnablePopUpContainer>   build a pop component for mobile app
>>>
>>>    and use the following code to call the popup
>>>
>>>    var pop:PopUpWindows =  new PopUpWindows();                              
>>>    pop.open(this,true);
>>>
>>>
>>>    but the popup always in top-left location of current page. how to make 
>>> the popup on screen certer
>>>
>>>    please help
>>>
>>>    Thanks for help
>>>
>>>    Mark
>>>             
>>>
>>>
>>>
>>> ------------------------------------
>>>
>>> --
>>> Flexcoders Mailing List
>>> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
>>> Alternative FAQ location: 
>>> https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
>>> Search Archives: 
>>> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links
>>>
>>>
>>>
>>>
>
>
>
> ------------------------------------
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Alternative FAQ location: 
> https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
> Search Archives: 
> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links
>
>
>
>

Reply via email to