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