3 Replies Latest reply on Sep 16, 2009 7:14 AM by jolpes

    How to instance an mx-component




      I have the following problem.


      1. I got a mx:ViewStack (main) with two components: an mx:HBox and a custom made (app:NewMailBox).

      2. In the main application I want to open the app:NewMailBox and initate it with a mail object



      The components in app:NewMailBox is null the first time I call method newMail.setMail() (please see code below). The next time i works.



      It seems like the mx components must be shown to be created.



      How do I create the instances of a mx components in a viewstack without showing it first. Please see code below for some clarification ;-)




          <mx:ViewStack id="mainStack">


                    <mx:DataGrid id="mailGrid" dataProvider="{mailList}"

                               click="mainStack.selectedIndex = 1; newMail.setMail(mailGrid.selectedItem);">

                               //The newMail mx components are null the first time setMail() method is called and the newMailBox component is shown

                               //The second time this meethod is called all mx child components to newMailBox is created and it works perfectly
                                <mx:DataGridColumn dataField="@subject" headerText="Title"/>



                <app:NewMailBox id="newMail"/>




      Best regards,