5 Replies Latest reply on Mar 8, 2008 10:26 PM by jlopes151

    Easy question (New to Flex)

    jlopes151 Level 1
      Have an app with a few modules. I load a module from the apps main screen, now I want to return to the main screen from the module. Hope to maintain the state of the main screen. So is there a way to do this?

      Another example is to activate a window from a Mian window then hit the esc key in that window returning to the Main.
        • 1. Re: Easy question (New to Flex)
          ntsiii Level 3
          What is you primary navigation container? ViewStack? Just set the selectedIndex to the main page.

          Tracy
          • 2. Re: Easy question (New to Flex)
            jlopes151 Level 1
            Its a TabNav the loads a module. I'm looking at History Management although I haven't gotten the Flex player to react to the Back button (alt+ left arrow)


            • 3. Re: Easy question (New to Flex)
              jlopes151 Level 1
              Actually the Main screen is in a TN that load a module in a VS. I want to return to the TN from the module. So some how have the module know about the TN in another .swf. The VS is to have 19 modules controlled in part from a panel in the TN.
              • 4. Re: Easy question (New to Flex)
                Gregory Lafrance Level 6
                ------------------------- ViewStack1.mxml ---------------------
                <?xml version="1.0" encoding="utf-8"?>
                <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns:comp="components.*"
                layout="vertical" width="100%" height="100%" >
                <comp:TopBar />
                <mx:HBox width="100%" height="100%">
                <comp:LeftBar />
                <mx:VBox width="100%" height="100%">
                <mx:ViewStack id="myViewStack" borderStyle="none" width="100%" height="100%">
                <mx:VBox id="home" width="100%">
                <comp:MainIntroText />
                <mx:HRule width="50%" height="3" strokeColor="0xCC3333"/>
                <comp:MainSecondaryText />
                <mx:HRule width="50%" height="3" strokeColor="0xCC3333"/>
                <comp:MainFinalText />
                </mx:VBox>
                <mx:VBox id="about" width="100%">
                <comp:About />
                </mx:VBox>
                <mx:VBox id="contact" width="100%">
                <comp:Contact />
                </mx:VBox>
                </mx:ViewStack>
                </mx:VBox>
                </mx:HBox>
                </mx:Application>
                ------------------------------- About.mxml -----------------------
                <?xml version="1.0" encoding="utf-8"?>
                <mx:HBox xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%">
                <mx:VBox width="65%">
                <mx:Text fontSize="14" width="100%" text="This page tells you about us." />
                </mx:VBox>
                </mx:HBox>

                ----------------------------------- Contact.mxml ---------------------------
                <?xml version="1.0" encoding="utf-8"?>
                <mx:HBox xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%">
                <mx:VBox width="65%">
                <mx:Text fontSize="14" width="100%" text="This page tells you how to contact us." />
                </mx:VBox>
                </mx:HBox>

                ------------------- LeftBar.mxml -------------------------
                <?xml version="1.0" encoding="utf-8"?>
                <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml" width="200" height="100%">
                <mx:LinkButton label="Adobe Labs - Flex"
                click="navigateToURL(new URLRequest(' http://labs.adobe.com/technologies/flex'), '_blank');"/>
                <mx:Spacer height="20"/>
                <mx:Label fontSize="16" text="Flex Blogs"/>
                <mx:LinkBar direction="vertical" width="90%" itemClick="navigateToURL(new URLRequest(event.item.data), '_blank');">
                <mx:Object label="Adobe Flex Team Blog" data=" http://weblogs.macromedia.com/flexteam/"/>
                <mx:Object label="Flex Blog Aggregator" data=" http://www.allyourflexarebelongtous.com/"/>
                <mx:Object label="Adobe Flex Blog Aggregator" data=" http://weblogs.macromedia.com/mxna/index.cfm?query=byCategory&#38;categoryId=5&#38;categor yName=Flex"/>
                </mx:LinkBar>
                <mx:Spacer height="20"/>
                <mx:Label fontSize="16" text="Example Flex Apps"/>
                <mx:LinkBar direction="vertical" id="addlRscList" width="90%" itemClick="navigateToURL(new URLRequest(event.item.data), '_blank');">
                <mx:Object label="Adobe Flex Store" data=" http://www.adobe.com/devnet/flex/samples/flex_store_v2/"/>
                <mx:Object label="Adobe Dashboard Example" data=" http://examples.adobe.com/flex2/inproduct/sdk/dashboard/dashboard.html"/>
                <mx:Object label="Buzzword Word Processor" data=" http://preview.getbuzzword.com/?s=true"/>
                <mx:Object label="Adobe Style Explorer" data=" http://examples.adobe.com/flex2/consulting/styleexplorer/Flex2StyleExplorer.html"/>
                <mx:Object label="Adobe Component Explorer" data=" http://examples.adobe.com/flex2/inproduct/sdk/explorer/explorer.html"/>
                </mx:LinkBar>
                </mx:VBox>

                ----------------------- MainFinalText.mxml ----------------------------
                <?xml version="1.0" encoding="utf-8"?>
                <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%">
                <mx:Text width="100%" fontSize="12"
                text="Here is the final text I want to show you." />
                </mx:VBox>

                --------------------------- MainIntroText.mxml -------------------------------
                <?xml version="1.0" encoding="utf-8"?>
                <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%">
                <mx:Text width="100%" fontSize="12"
                text="Here is the main text I want to show you." />
                </mx:VBox>

                ----------------------- MainSecondaryText.mxml --------------------------------
                <?xml version="1.0" encoding="utf-8"?>
                <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%">
                <mx:Text width="100%" fontSize="12"
                text="Here is the secondary text I want to show you." />
                </mx:VBox>

                --------------- TopBar.mxml --------------------------------
                <?xml version="1.0" encoding="utf-8"?>
                <mx:HBox xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%">
                <mx:Script>
                <![CDATA[
                private function goToViews(view:String):void {
                if(view == "home"){
                this.parentApplication.myViewStack.selectedChild=this.parentApplication.home;
                }
                if(view == "about"){
                this.parentApplication.myViewStack.selectedChild=this.parentApplication.about;
                }
                if(view == "contact"){
                this.parentApplication.myViewStack.selectedChild=this.parentApplication.contact;
                }
                }
                ]]>
                </mx:Script>
                <mx:LinkButton label="MySnazzyLogo" fontSize="20" click="goToViews('home');" />
                <mx:VBox width="100%">
                <mx:HBox width="100%">
                <mx:Spacer width="100%" />
                <mx:LinkBar fontSize="14" itemClick="goToViews(String(event.item.data));">
                <mx:Array>
                <mx:Object label="About Us" data="about"/>
                <mx:Object label="Contact Us" data="contact"/>
                </mx:Array>
                </mx:LinkBar>
                </mx:HBox>
                <mx:HBox width="100%">
                <mx:Spacer width="150" />
                <mx:Label fontSize="25" text="Here is Some Additional Text" />
                </mx:HBox>
                </mx:VBox>
                </mx:HBox>
                • 5. Re: Easy question (New to Flex)
                  jlopes151 Level 1
                  Here's my test code

                  ---- The application ----

                  <?xml version="1.0" encoding="utf-8"?>
                  <!-- Test Nagigation -->
                  <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
                  <mx:Script>
                  <![CDATA[
                  import mx.collections.ArrayCollection;
                  import mx.modules.*;
                  import mx.managers.SystemManager;
                  import mx.controls.Label;
                  import mx.controls.Alert;
                  import flash.events.Event;

                  private var selectedrpt:String; // the current report to display
                  private var currentmod:ModuleLoader;

                  private function activateSomeSWF(swf:String):void {
                  /*
                  Could say the reports view stack is hidden behind the Teacher report
                  panel
                  must set the view stack to visible or the report will not display
                  */
                  myViewStack.visible=true;
                  if(swf == "someswf"){
                  myViewStack.selectedChild=someswf;
                  }else{
                  myViewStack.selectedChild=someothr;
                  }// some erro message no report selected.

                  }

                  ]]>
                  </mx:Script>
                  <mx:ViewStack id="myViewStack" borderStyle="solid" width="100%" height="100%"
                  visible="true" historyManagementEnabled="true" >

                  <mx:Canvas id="main" >
                  <mx:VBox height="100%" width="100%">

                  <mx:TabNavigator id="tn" width="100%" height="100%" backgroundColor="#ffffff" historyManagementEnabled="true">

                  <mx:Canvas label="Tab one">
                  <mx:Label text="Tab One" color="#000000" click="activateSomeSWF('someswf');" textDecoration="underline"/>
                  </mx:Canvas>

                  <mx:Canvas label="Tab Two">
                  <mx:Label text="Tab Two Screen" color="#000000"/>
                  </mx:Canvas>

                  <mx:Canvas label="Tab Three">
                  <mx:Label text="Tab Three Screen" color="#000000"/>
                  </mx:Canvas>

                  </mx:TabNavigator>

                  </mx:VBox>

                  </mx:Canvas>

                  <mx:Canvas id="someswf" label="SomeSWF" backgroundColor="#FFFFFF" visible="false">
                  <mx:ModuleLoader id="modsomswf" width="100%" height="100%" url="Some.swf" />
                  </mx:Canvas>

                  <mx:Canvas id="someothr" label="SomeSWF" backgroundColor="#FFFFFF" visible="false">
                  <mx:Text text="Some other View"/>
                  </mx:Canvas>

                  </mx:ViewStack>

                  </mx:Application>

                  ---- The Module ----

                  <?xml version="1.0" encoding="utf-8"?>
                  <mx:Module xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300">
                  <!-- Going to try NavigateToUrl -->
                  <mx:LinkButton x="47" y="59" label="return to Parent..." width="154"/>
                  </mx:Module>