Question

I have an Accordion component in Flex that has two children, at the load of my page, I want to give the textvalue of a textfield in the first children to a textfield in the second children by using actionscript, but its faild

nb : when I click the secode children and I return to pass the textvalue from the first children, the action succeed!

                <mx:HBox width="100%" height="310" horizontalAlign="center">
                        <mx:Accordion id="accordion1" width="100%" height="310" historyManagementEnabled="true">
            <!-- child 1--><mx:VBox id="theme_resultat" width="95%" height="95%"  
                                     label="Résultat" horizontalAlign="center"
                                     verticalAlign="middle">
                                <s:HGroup left="0" right="0" bottom="0" width="98%"
                                          horizontalAlign="right">
                                    <s:TextInput id="doc"/>
                                    <mx:Button id="btnAdd" label="Add"
                                               click="add_text(event)"
                                               icon="@Embed('assets/images/add.png')"
                                               paddingLeft="3" paddingRight="3"/>
                                </s:HGroup>

                            </mx:VBox>
            <!-- child 2--><mx:VBox id="theme_detail" width="95%" height="95%" label="Détail"
                                     verticalAlign="middle">
                                <mx:VBox width="100%" height="150" horizontalAlign="center">
                                    <s:HGroup>
                                        <mx:FormItem label="Titre:" paddingLeft="5">
                                            <mx:TextInput id="doc_titre"/>
                                        </mx:FormItem>
                                    </s:HGroup>                             
                                </mx:VBox>
                            </mx:VBox>
                        </mx:Accordion>
            </mx:HBox>
      protected function add_text(event:MouseEvent):void
        {
                accordion1.selectedIndex=1;
                doc_titre.text = doc.text;
            }
        }

when I click add I move to the second child, but the (mx:TextInput id="doc_titre") dont have the value of (s:TextInput id="doc"/)

for the second time I return to the child 1 and I click add, then I move to the second child and I find the value of (s:TextInput id="doc") in (mx:TextInput id="doc_titre")

Was it helpful?

Solution

What happens exactly? I think your problem may be caused by the fact that the components on the second children are not created until that view is opened, There are many solution for this, you could write some code in the creation complete oof the second view that will load the correct value, you can use databinding to bind the text inputs to the same string or you can try setting creationPolicy to all. My answer is based on my above assumption so if I am wrong please give more details.

Check this http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7cb8.html#WS2db454920e96a9e51e63e3d11c0bf69084-7ae5 and try setting the creationPolicy to all then let us know if the problem is solved

OTHER TIPS

Use createDefferedContent() instead:

for (var i:int = 0; i < accordion.numChildren; i++)
{
    (accordion.getElementAt(i) as NavigatorContent).createDeferredContent();
}

This method creates the children and their components in the background. Don't use creationPolicy as I did since this causes memory-related issues.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top