0 Replies Latest reply on Dec 26, 2010 11:06 AM by edwinmerced

    Stuck with a menu bar (Some help please)

    edwinmerced Level 1

      I need some orientation on putting to work a MenuBar. Each item (option in the menubar) should load a different module:

       

      This is what I have:

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:mx="library://ns.adobe.com/flex/mx" width="960" height="590" creationComplete="cmenu()">
         
          <fx:Declarations>
              <fx:XMLList id="menuXML">
                  <fx:menuitem label="Home" />
                 
                  <fx:menuitem label="Unit 1">
                      <fx:menuitem label="Module 1.1" data="11" type="radio" groupName="one">
                          <fx:menuitem label="Topic 1.1.1" data="111" type="radio" groupName="one"/>
                          <fx:menuitem label="Topic 1.1.2" data="112" type="radio" groupName="one"/>
                          <fx:menuitem label="Topic 1.1.3" data="113" type="radio" groupName="one"/>
                          <fx:menuitem label="Topic 1.1.4" data="114" type="radio" groupName="one"/>
                      </fx:menuitem>
                      <fx:menuitem label="Module 1.2" data="12" type="radio" groupName="one">
                          <fx:menuitem label="Topic 1.2.1" data="121" type="radio" groupName="one"/>
                          <fx:menuitem label="Topic 1.2.2" data="122" type="radio" groupName="one"/>
                          <fx:menuitem label="Topic 1.2.3" data="123" type="radio" groupName="one"/>
                          <fx:menuitem label="Topic 1.2.4" data="124" type="radio" groupName="one"/>
                      </fx:menuitem>
                      <fx:menuitem label="Module 1.3" data="13" type="radio" groupName="one">
                          <fx:menuitem label="Topic 1.3.1" data="131" type="radio" groupName="one"/>
                          <fx:menuitem label="Topic 1.3.2" data="132" type="radio" groupName="one"/>
                          <fx:menuitem label="Topic 1.3.3" data="133" type="radio" groupName="one"/>
                          <fx:menuitem label="Topic 1.3.4" data="134" type="radio" groupName="one"/>
                      </fx:menuitem>
                      <fx:menuitem label="Module 1.4" data="14" type="radio" groupName="one">
                          <fx:menuitem label="Topic 1.4.1" data="141" type="radio" groupName="one"/>
                          <fx:menuitem label="Topic 1.4.2" data="142" type="radio" groupName="one"/>
                          <fx:menuitem label="Topic 1.4.3" data="143" type="radio" groupName="one"/>
                          <fx:menuitem label="Topic 1.4.4" data="144" type="radio" groupName="one"/>
                      </fx:menuitem>
                  </fx:menuitem>
                 
                  <fx:menuitem label="Unit 2">
                      <fx:menuitem label="Module 2.1" data="21" type="radio" groupName="one">
                          <fx:menuitem label="     Topic 2.1.1" data="211" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 2.1.2" data="212" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 2.1.3" data="213" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 2.1.4" data="214" type="radio" groupName="one"/>
                      </fx:menuitem>
                      <fx:menuitem label="Module 2.2" data="22" type="radio" groupName="one">
                          <fx:menuitem label="     Topic 2.2.1" data="221" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 2.2.2" data="222" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 2.2.3" data="223" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 2.2.4" data="224" type="radio" groupName="one"/>
                      </fx:menuitem>
                      <fx:menuitem label="Module 2.3" data="23" type="radio" groupName="one">
                          <fx:menuitem label="     Topic 2.3.1" data="231" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 2.3.2" data="232" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 2.3.3" data="233" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 2.3.4" data="234" type="radio" groupName="one"/>
                      </fx:menuitem>
                      <fx:menuitem label="Module 2.4" data="24" type="radio" groupName="one">
                          <fx:menuitem label="     Topic 2.4.1" data="241" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 2.4.2" data="242" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 2.4.3" data="243" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 2.4.4" data="244" type="radio" groupName="one"/>
                      </fx:menuitem>
                  </fx:menuitem>
                 
                  <fx:menuitem label="Unit 3">
                      <fx:menuitem label="Module 3.1" data="31" type="radio" groupName="one">
                          <fx:menuitem label="     Topic 3.1.1" data="311" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 3.1.2" data="312" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 3.1.3" data="313" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 3.1.4" data="314" type="radio" groupName="one"/>
                      </fx:menuitem>
                      <fx:menuitem label="Module 3.2" data="32" type="radio" groupName="one">
                          <fx:menuitem label="     Topic 3.2.1" data="321" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 3.2.2" data="322" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 3.2.3" data="323" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 3.2.4" data="324" type="radio" groupName="one"/>
                      </fx:menuitem>
                      <fx:menuitem label="Module 3.3" data="33" type="radio" groupName="one">
                          <fx:menuitem label="     Topic 3.3.1" data="331" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 3.3.2" data="332" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 3.3.3" data="333" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 3.3.4" data="334" type="radio" groupName="one"/>
                      </fx:menuitem>
                      <fx:menuitem label="Module 3.4" data="34" type="radio" groupName="one">
                          <fx:menuitem label="     Topic 3.4.1" data="341" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 3.4.2" data="342" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 3.4.3" data="343" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 3.4.4" data="344" type="radio" groupName="one"/>
                      </fx:menuitem>
                  </fx:menuitem>

       

                  <fx:menuitem label="Unit 4">
                      <fx:menuitem label="Module 4.1" data="41" type="radio" groupName="one">
                          <fx:menuitem label="     Topic 4.1.1" data="411" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 4.1.2" data="412" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 4.1.3" data="413" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 4.1.4" data="414" type="radio" groupName="one"/>
                      </fx:menuitem>
                      <fx:menuitem label="Module 4.2" data="42" type="radio" groupName="one">
                          <fx:menuitem label="     Topic 4.2.1" data="421" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 4.2.2" data="422" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 4.2.3" data="423" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 4.2.4" data="424" type="radio" groupName="one"/>
                      </fx:menuitem>
                      <fx:menuitem label="Module 4.3" data="43" type="radio" groupName="one">
                          <fx:menuitem label="     Topic 4.3.1" data="431" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 4.3.2" data="432" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 4.3.3" data="433" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 4.3.4" data="434" type="radio" groupName="one"/>
                      </fx:menuitem>
                      <fx:menuitem label="Module 4.4" data="44" type="radio" groupName="one">
                          <fx:menuitem label="     Topic 4.4.1" data="441" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 4.4.2" data="442" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 4.4.3" data="443" type="radio" groupName="one"/>
                          <fx:menuitem label="     Topic 4.4.4" data="444" type="radio" groupName="one"/>
                      </fx:menuitem>
                  </fx:menuitem>

       

              </fx:XMLList>
             
          </fx:Declarations>
          <fx:Script>
              <![CDATA[
                  import mx.controls.Menu;
                  import mx.core.FlexGlobals;
                  import mx.events.MenuEvent;
                 
                  import org.osmf.utils.URL;

       

                  private function cmenu():void {
                      var customMenuItem1:ContextMenuItem = new ContextMenuItem("© Copyright 2011 Jeje Designs All rights reserved", false, false);
                      var customMenuItem2:ContextMenuItem = new ContextMenuItem("Resources and Materials Application Version 1.0 Build 1 | October 1, 2010 | Guaynabo, PR", false, false);
                      var customMenuItem3:ContextMenuItem = new ContextMenuItem("Devigner: Edwin Merced | em@jejedesigns.com", false, false);
                      var contextMenuCustomItems:Array = FlexGlobals.topLevelApplication.contextMenu.customItems;
                      contextMenuCustomItems.push(customMenuItem1);
                      contextMenuCustomItems.push(customMenuItem2);
                      contextMenuCustomItems.push(customMenuItem3);
                  }
                 
                 
                  [Bindable]
                  public var ModuleName:String = "PRELIMINARIES.swf";
         
                  private function ModuleLoad():void {
                     
                      switch(ModuleName)
                      {
                          case 0:
                              trace("PRELIMINARIES.swf");
                              break;
                          case 1:
                              trace("U1M1T1.swf");
                              break;
                          case 2:
                              trace("U1M1T2.swf");
                              break;
                          case 3:
                              trace("U1M1T3.swf");
                              break;
                          case 4:
                              trace("U1M1T4.swf");
                              break;
                          case 5:
                              trace("U1M2T1.swf");
                              break;
                          case 6:
                              trace("U1M2T2.swf");
                              break;
                          default:
                              trace("U1M2T3.swf");
                              break;
                      }

       

                     
                  }

       


             
              ]]>
      </fx:Script>
         
          <s:BorderContainer x="0" y="0" width="960" height="590">
          <s:Label x="15" y="570" text="2010 Copyright Jeje Deisgns All rights reserved" width="300"/>
          <s:Label x="12.9" y="11.45" text="Course Identification" width="363"/>
          <mx:ApplicationControlBar
                                    dock="false" x="105" y="40">
              <mx:MenuBar height="100%"
                          dataProvider="{menuXML}"
                          labelField="@label"
                          showRoot="true" id="MainMenu" />
                                   
          </mx:ApplicationControlBar>

       

       

       

                  <mx:ModuleLoader width="750" height="450" url="{ModuleName}" id="mainModule" horizontalCenter="0" verticalCenter="21"></mx:ModuleLoader>

       

          <mx:TextArea
              width="146" height="73"
              id="ta1" x="790.1" y="15.25" fontSize="8"/>
          </s:BorderContainer>

       

      </s:Application>

       

      Thanks for any help