Let me see if I can explain it (And someone else can correct me if I
am wrong).

In your application you create the loginForm:

public var login:MyLoginForm = new MyLoginForm();

then with the button you add it to the display list:

PopUpManager.addPopUp(login, this, true);

When you close the popup:

PopUpManager.removePopUp(this);

Flex removes it from the Display List. Note that the loginForm object
still exists (It is in the login variable). When you click the button
again Flex puts the popup back on the display list and displays it.
Anything a user has added to textinputs will still be there. There is
no logic to save the state of combo boxes (Or check boxes or radio
buttons...) so they will default back to the first item in the list.

What you would need to do is add logic to save the state of these
controls on the click of the close button and then re-instate these
saved states when re-opening the loginForm.


HTH


Steve


--- In flexcoders@yahoogroups.com, "dfrank76" <[EMAIL PROTECTED]> wrote:
>
> I am loading data in a popup title window and then I'd like to reuse 
> that title window instance with all the loaded data an user input data 
> any time the user clicks the button to pop it up.  I'm having trouble 
> with bound fields...
> 
> I implemented it using an instance of a custom TitleWindow that is 
> referenced from the main app, and then use addPopup/removePopup to 
> show/display it.  In the example below, click the button to pop up the 
> TitleWindow.  Type any text into the TextInput.  Then in the ComboBx 
> either select original2 from the dropdown or click to change the 
> dataProvider.  Close the popup and reopen and you will see that the 
> text you entered into popup is still there, but any change made to the  
> combo box has been wiped out.  
> 
> Is this a bug?  If this is how it is supposed to work, can someone 
> walk me through why it works this way?  Why are the mxml binds 
> refreshed when the underlying data they are bound to did not change?  
> Why are the mxml binds wiping out the user entered changes?  Is there 
> any way to prevent this bind refresh from happening?
> 
> 
> 
> Below is the simplified example:
> 
> <?xml version="1.0"?>
> <!-- MyLoginForm.mxml -->
> <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml";>
>     
>     <mx:Script>
>         <![CDATA[
>             import mx.managers.PopUpManager;
>             
>             [Bindable] private var provider1:XML = <XML><record 
> label="original1"/><record label="original2"/></XML>;
>             [Bindable] private var provider2:XML = <XML><record 
> label="new1"/><record label="new2"/></XML>;
>                         
>             private function swapProviders():void {
>                 combo1.dataProvider = provider2.record;
>             }
>         ]]>
>     </mx:Script>
> 
>     <mx:Form>
>         <mx:FormItem label="Text field test">
>             <mx:TextInput id="text1" width="100%"/>
>         </mx:FormItem> 
>         <mx:FormItem label="Bound droplist">
>             <mx:ComboBox id="combo1" width="100%" 
> dataProvider="{provider1.record}" labelField="@label"/>
>         </mx:FormItem> 
>     </mx:Form>
>     <mx:HBox> 
>         <mx:Button click="swapProviders();" label="Swap data 
> providers"/> 
>         <mx:Button label="Close" 
> click="PopUpManager.removePopUp(this);"/> 
>     </mx:HBox> 
> </mx:TitleWindow>
> 
> 
> <?xml version="1.0"?>
> <!-- Main.mxml -->
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";>
> 
>     <mx:Script>
>         <![CDATA[
>             import mx.managers.PopUpManager;
>             import MyLoginForm;            
>             
>             public var login:MyLoginForm = new MyLoginForm();
> 
>             private function showLogin():void {
>                 PopUpManager.addPopUp(login, this, true);
>             }
>         ]]>
>     </mx:Script>
>     
>     <mx:VBox width="300" height="300">  
>         <mx:Button click="showLogin();" label="Login"/>
>     </mx:VBox>
> </mx:Application>
>


Reply via email to