Here's a sample app I created that illustrates the problem.  Notice that you have to flip over to Panel 2, then back to Panel 1 for the checkbox and the radio button bindings to fire in Panel1.
 
There are two files you need to compile
 
1) the main test app
 
<?xml version="1.0" encoding="UTF-8"?>
<mx:Application pageTitle="Canvas Test" width="100%" height="100%" creationComplete="initObj();"
    xmlns:mx=" http://www.macromedia.com/2003/mxml">
 <mx:Script>
  <![CDATA[
   var dataArray:Array;
   
   function initObj() {
    dataArray = new Array({NAME: "Fred", MALE: true, COLLEGEGRAD: true},
               {NAME: "Myra", MALE: false, COLLEGEGRAD: true});
    handleViewChange();
   }
   
   function handleViewChange() {
    viewTest.selectedChild.activate(dataArray[viewTest.selectedIndex ]);
   }
   ]]>
 </mx:Script> 
 
 
 <mx:LinkBar id="configLinks" dataProvider="viewTest" horizontalAlign="center" width="100%"/>
 <mx:ViewStack id="viewTest" change="handleViewChange();">
  <p:TestPanel xmlns:p="*" label="Panel 1" title="Panel 1"/>
  <p:TestPanel xmlns:p="*" label="Panel 2" title="Panel 2"/>  
 </mx:ViewStack>
</mx:Application>
 
2) the TestPanel

<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.macromedia.com/2003/mxml" width="100%" height="100%">

 <mx:Script>
  <![CDATA[
   var dataObject:Object;
   
   function activate(o:Object) {
    dataObject = o;
   }   
   ]]>
 </mx:Script> 
 
 <mx:Binding source=" txtName.text" destination="dataObject.NAME"/>
 <mx:Binding source="rdMale.selected" destination="dataObject.MALE"/>
 <mx:Binding source="chkGrad.selected" destination=" dataObject.COLLEGEGRAD"/> 

 <mx:FormItem direction="horizontal" labelWidth="100" label="Name">
  <mx:TextInput id="txtName" text="{dataObject.NAME}"/>
 </mx:FormItem>   
 <mx:RadioButtonGroup id="sexGroupRadio"/>
 <mx:FormItem direction="horizontal" labelWidth="100" label="Sex">
  <mx:RadioButton id="rdMale" label="Male" selected="{ dataObject.MALE}" groupName="sexGroupRadio"/>
  <mx:RadioButton id="rdFemale" label="Female" selected="{!dataObject.MALE}" groupName="sexGroupRadio"/>
 </mx:FormItem>
 <mx:FormItem direction="horizontal" labelWidth="100" label="Graduate">
  <mx:CheckBox id="chkGrad" selected="{dataObject.COLLEGEGRAD}"/>
 </mx:FormItem>   
</mx:Panel>


In this example, both are in the same directory.
 
- Jaime
 
On 10/27/05, Jaime Bermudez <[EMAIL PROTECTED]> wrote:
I'm wondering if any other flexcoders have come across this issue.  I have a Panel component within an auto Viewstack (not sure if the Viewstack is causing anything).  The panel has an activate() method that gets hit once the viewstack index selects - the activate method is where remote data calls are being made.  So, basically the Panel is a view for a data object.  I use two-way binding to set various controls ( e.g. checkboxes, radiobuttons) that reflect fields on the object.  Here's an example:
 
 <mx:Binding source="chkField1.selected" destination="dataObject.Field1"/>
 
  <mx:CheckBox id="chkField1" label="Field 1" selected="{dataObject.Field1}" click="formHasChanged()"/>
 
What I'm finding is that the first time the Panel is hit, the selected property isn't set correctly, but on subsequent visits to the component the binding works fine.  The checkbox binding works fine if I don't include the mx:Binidng object, but the binding object is convenient for dealing w/ saves ( i.e. I can send the dataObject directly).  I ended up creating custom Checkboxes, RadioButtons, and ComboBoxes that have a duplicate selected or selectedItem field that I can use in the Binding object, but I was just wondering if there was another way around this.  Is this a FLEX bug?
 
Thanks,
 
Jaime



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to