3 Replies Latest reply on Jul 24, 2009 4:54 AM by GG_81

    Problem in accessing the ViewStack within modules

    GG_81

      Hi,

           I have one application mxml and two modules mxml. In the application mxml i'm just using the moduleLoader with the url property to load the first module. First module is having viewStack. From this module i'm able to load the another module by setting the event click as click="viewStack.selectedChild=dS"  and moduleloader as <mx:ModuleLoader id="dS" url="dataSource.swf" width="100%" height="100%"/>.

       

      Here, from one module to another module is working fine but when i press the back button from module2 so that i can come back to module1, its not working. i have putted the following code under the click event of button as  click="parentApplication.viewStack.selectedChild=parentApplication.panelSqlService".

       

      I am also pasting the code snippet.

       

      Simple Application MXML

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
      <mx:Script>
          <![CDATA[
              import mx.messaging.messages.ErrorMessage;
              //Fix for flex history manager
              import mx.managers.*;
              private var hist:HistoryManager;
              private var drg:DragManager;
              private var erMsg:ErrorMessage;
          ]]>
      </mx:Script>
         
              <mx:ModuleLoader url="sqlService.swf" width="100%" height="100%"/>   
         
         
      </mx:Application>

        • 1. Re: Problem in accessing the ViewStack within modules
          GG_81 Level 1

          Hi,

               I have one application mxml and two modules mxml. In the application mxml i'm just using the moduleLoader with the url property to load the first module. First module is having viewStack. From this module i'm able to load the another module by setting the event click as click="viewStack.selectedChild=dS"  and moduleloader as <mx:ModuleLoader id="dS" url="dataSource.swf" width="100%" height="100%"/>.

           

          Here, from one module to another module is working fine but when i press the back button from module2 so that i can come back to module1, its not working. i have putted the following code under the click event of button as  click="parentApplication.viewStack.selectedChild=parentApplication.panelSqlServi ce".

           

          I am also pasting the code snippet.

           

          Simple Application MXML

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
          <mx:Script>
              <![CDATA[
                  import mx.messaging.messages.ErrorMessage;
                  //Fix for flex history manager
                  import mx.managers.*;
                  private var hist:HistoryManager;
                  private var drg:DragManager;
                  private var erMsg:ErrorMessage;
              ]]>
          </mx:Script>
             
                  <mx:ModuleLoader url="sqlService.swf" width="100%" height="100%"/>   
             
             
          </mx:Application>

           

          Here i'm just loading the module1.

           

          First Module Code(sqlService.swf)

           

          <mx:ViewStack id="viewStack" width="50%" height="70%">

           

          <mx:Panel id="panelSqlService">

           

          <mx:LinkButton icon="@Embed(source='../resources/add.png')" toolTip="Data Source" id="newActionLnk" paddingTop="5" click="viewStack.selectedChild=dS"/>

           

          </mx:Panel>

           

          <mx:ModuleLoader id="dS" url="dataSource.swf" width="100%" height="100%"/>


          </mx:ViewStack>

           

          From here, i am able to go to Second Module.


          Second Module Code(dataSource.swf)

           

          <mx:Button id="back" label="Back" click="parentApplication.viewStack.selectedChild=parentApplication.panelSqlService"/>

           

          Here when press the back, i get the error and not able to go back to first module screen.

           

           

           

          Please help me in solving this problem.

           

           

          Thanxs

           

          Gaurav

          • 2. Re: Problem in accessing the ViewStack within modules
            Gregory Lafrance Level 6

            When you say it is not working, what do you mean? Are you getting an error? Rather than use parentDocumednt, you could use mx.core.Application.application or parentDocument, but often it is even better to use custom events. You might have to add the event listeners for the custom events to the systemManager. Popups are not in the same display list as the application, so listening at the systemManager level is often necessary, because it is in the same display list.

             

                          stage

                             |

                 systemManager

                |                      |

            popup          Application

             

            These links may help answer your question:

             

            http://www.google.com/search?hl=en&q=flex+3+dispatching+custom+events&aq=0&oq=Flex+3+dispa tching+c&aqi=g1

             

            http://gregjessup.com/flex-3-custom-event-listener-with-popup-window/

             

            http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=2&postI d=11246

             

            If this post answers your question or helps, please mark it as such.

            • 3. Re: Problem in accessing the ViewStack within modules
              GG_81 Level 1

              Hi,

                   I'm attaching the error image which i am getting when i press the back button. Basically i want to see the previous screen(navigation between these 2 modules) as normal screen, no popup stuff.

               

              Thanxs

               

              Gaurav