I got it to work using the following approach: (please let me know if
i've done something stupid)

index.mxml i have this function
   public var isOpen : Boolean = false;
                        
                public function openWin():void{
                        if(!isOpen){
                        PopUpManager.createPopUp(this,main,false);      
                        isOpen = true;
                        }

in main.mxml i have this function

                        public function closeWindow():void
                        {
                                PopUpManager.removePopUp(this);
                                Application.application.isOpen = false;
                        }//closeWindow 


Rohan

--- In flexcoders@yahoogroups.com, "Rohan Pinto" <[EMAIL PROTECTED]> wrote:
>
> Hi Mike,
> 
> i did follow all threrads and tried every possible combination... I
> could not get it to work..
> 
> here's my index.mxml
> 
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> autoLayout="true" layout="vertical" 
>       creationComplete="openWin()"
>       horizontalScrollPolicy="off" verticalScrollPolicy="auto"
>       height="100%" width="100%"
>       paddingTop="0" paddingBottom="0" x="0" y="0"
>       xmlns:com="com.*"
>       applicationComplete="initApp()"
>       >
> <mx:Script>
>       <![CDATA[
>               import mx.containers.TitleWindow;
>               import mx.effects.Move;
>               import mx.controls.Menu;
>               import mx.events.MenuEvent;     
>               import mx.managers.PopUpManager;
>         import flash.net.URLRequest;  
>         import flash.events.MouseEvent; 
> 
>       [Bindable]
>         public var vkey:String;
>           
>         [Bindable]
>         public var chid:String;
>         
>         public function initApp():void{
>               vkey=Application.application.parameters.vkey;
>                 chid=Application.application.parameters.chid;
>         }
> 
> 
>           public var isOpen : Boolean = false;
>                       
>               private function openWin():void{
>                       if(!isOpen){
>                       PopUpManager.createPopUp(this,main,false);      
>                       isOpen = true;
>                       }
>                               
>       
>                       PopUpManager.createPopUp(this,Desktop_Control,false);   
> 
>               }
> 
>                               
>       ]]>
> </mx:Script>
> <mx:ApplicationControlBar dock="true" paddingTop="0" paddingLeft="0"
> paddingRight="0" paddingBottom="0" x="0" y="0" width="100%"
> height="40" verticalAlign="middle"> 
> <com:LinkImage source="images/logo.png" maintainAspectRatio="true"
> buttonMode="true" imageURL="/" click="openWin()" />
> </mx:ApplicationControlBar>
> </mx:Application>
> 
> and here's my main.mxml
> <mx:TitleWindow width="800" height="500" autoLayout="true"
> layout="absolute" title="Web Desktop" showCloseButton="true" 
>               xmlns:mx="http://www.adobe.com/2006/mxml";
>               backgroundColor="#ffffff"
>               verticalGap="0" horizontalCenter="0" verticalCenter="0"
>               x="10" y="55"
>               dropShadowEnabled="true"
>               creationComplete="init()"
>               close="closeWindow()"
>               xmlns:ns1="*">
>    <mx:Script>
>         <![CDATA[
>                       import mx.core.Application;
>                       import mx.managers.PopUpManager;
>                   
>                   public var isOpen : Boolean = true;
>                   //called by the close event raised byclicking the close 
> button
>                       public function closeWindow():void
>                       {
>                               PopUpManager.removePopUp(this);
>                               isOpen = false;
>                       }//closeWindow 
>                       
>       
>         ]]>
>     </mx:Script>
> <mx:VBox x="0" y="0" borderStyle="none" paddingTop="20"
> paddingBottom="10" paddingLeft="10" paddingRight="10" width="100%"
> height="99%">
> <ns1:FrontPageRecentlyViewedVideos/>
> </mx:VBox>
> </mx:TitleWindow>
> 
> i just cant figure out what i'm doing wrong.... 
> 
> Rohan
> --- In flexcoders@yahoogroups.com, "Michael Schmalle"
> <teoti.graphix@> wrote:
> >
> > Hi,
> > 
> > I gave an answer to this a couple threads back. See all the threads
> to this
> > post and you will see the answer.
> > 
> > Peace, Mike
> > 
> > On 5/31/07, Rohan Pinto <rohan@> wrote:
> > >
> > >   exactly..
> > >
> > > see my demo app: http://demo.rohanpinto.com
> > >
> > > if you click on the logo, the TileWindow opens over and over
again...
> > > i want to restrict that to just one instance.. any advise..
please.. ?
> > >
> > > Rohan
> > > http://konkan.tv
> > >
> > > --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>,
> "Michael
> > > Schmalle"
> > > <teoti.graphix@> wrote:
> > > >
> > > > Hi,
> > > >
> > > > There is no problem with what you have but... his question was,
> > > >
> > > > > how to i prevent a popup if the popup TileWindow is already
Open..
> > > >
> > > > That means, he is asking how does he only create ONE TitleWindow
> after a
> > > > user has clicked the button to create it the first time.
> > > >
> > > > There are two ways, using a boolean flag in the application that
> > > holds the
> > > > button or doing what I showed by checking if the instance is not
> > > null in the
> > > > application.
> > > >
> > > > What you said the first time would work IF the boolean flag is in
> > > the actual
> > > > application. It wouldn't work if the flag was in the title window
> > > because
> > > > the popup manager would have already created another popup on
> top of the
> > > > first popup.
> > > >
> > > > Peace, Mike
> > > >
> > > > On 5/31/07, Flexing... <eaiesb@> wrote:
> > > > >
> > > > > Hi Mike,
> > > > >
> > > > > >> The manager will have already created the instance and the
> > > TitleWindow
> > > > > would have to use removePopUp() which is not optimum.
> > > > > I didn't understand what is the issue in using removePopup
inside
> > > > > Titlewindow ?
> > > > >
> > > > > Let say if I write the following to handle window closure , is
> > > there any
> > > > > issue in this ?
> > > > >
> > > > >
> > > > > <mx:TitleWindow showCloseButton="true" close="{onClose(event)}">
> > > > > <mx:Script>
> > > > > <![CDATA[
> > > > > public var isOpen : Boolean = true;
> > > > >
> > > > > private function onClose(event : Event) : void
> > > > > {
> > > > > PopUpManager.removePopUp(this);
> > > > > isOpen = false;
> > > > > }
> > > > >
> > > > > public function setOpen() : void
> > > > > {
> > > > > isOpen = true;
> > > > > }
> > > > > ]]>
> > > > > </mx:TitleWindow>
> > > > >
> > > > >
> > > > > Thanks
> > > > >
> > > > > On May 31, 2007, at 5:46 PM, Michael Schmalle wrote:
> > > > >
> > > > > Hi,
> > > > >
> > > > > I don't think a boolean flag will help here. The manager
will have
> > > already
> > > > > created the instance and the TitleWindow would have to use
> > > removePopUp()
> > > > > which is not optimum.
> > > > >
> > > > > You need to take that call out of the mxml and create a click
> > > handler for
> > > > > the button.
> > > > >
> > > > > .. in your app
> > > > >
> > > > > private var popUpWindow:TitleWindow;
> > > > >
> > > > > private function button_clickHandler(event:MouseEvent):void
> > > > > {
> > > > > if (!popUpWindow)
> > > > > {
> > > > > popUpWindow = TitleWindow(
> > > PopUpManager.createPopUp(this,main,false));
> > > > >
> > > > > }
> > > > > }
> > > > >
> > > > > ....
> > > > >
> > > > > <mx:Button click="button_clickHandler(event) ;"/>
> > > > >
> > > > > Peace, Mike
> > > > >
> > > > > On 5/31/07, Flexing... <eaiesb@> wrote:
> > > > > >
> > > > > > Store a boolean (flag) in your titlewindow to indicate
> whether the
> > > > > > Window is already open or not.
> > > > > >
> > > > > > On May 31, 2007, at 9:56 AM, Rohan Pinto wrote:
> > > > > >
> > > > > > how to i prevent a popup if the popup TileWindow is already
> Open..
> > > > > >
> > > > > > ie: in my conrtol i have
> > > > > >
> > > > > > click="PopUpManager.createPopUp( this,main,false);"
> > > > > >
> > > > > > if the user clicks this several times, it opens up multiple
> > > popups of
> > > > > > the same window. how do i prevent the popup to just 1
instance ?
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Teoti Graphix
> > > > > http://www.teotigra <http://www.teotigraphix.com>phix.com
> > > > >
> > > > > Blog - Flex2Components
> > > > > http://www.flex2com <http://www.flex2components.com>ponents.com
> > > > >
> > > > > You can find more by solving the problem then by 'asking the
> > > question'.
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Teoti Graphix
> > > > http://www.teotigraphix.com
> > > >
> > > > Blog - Flex2Components
> > > > http://www.flex2components.com
> > > >
> > > > You can find more by solving the problem then by 'asking the
> question'.
> > > >
> > >
> > >  
> > >
> > 
> > 
> > 
> > -- 
> > Teoti Graphix
> > http://www.teotigraphix.com
> > 
> > Blog - Flex2Components
> > http://www.flex2components.com
> > 
> > You can find more by solving the problem then by 'asking the
question'.
> >
>


Reply via email to