Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sounds to me like the exact component you're after is the <code>TabNavigator</code> (<a href="http://livedocs.adobe.com/flex/3/html/help.html?content=navigators_4.html" rel="nofollow noreferrer">Adobe docs</a>).</p> <p>It's fairly simple to use. Each child of the the <code>TabNavigator</code> component represents a tab page of content (note that children must be containers such as <code>Canvas</code> or <code>VBox</code>), and the <code>label</code> property of the child is used to represent the label on the tab itself.</p> <p>A very simple web site using tabs might look something like:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" height="100%" pageTitle="My Website" /&gt; &lt;mx:TabNavigator width="100%" height="100%"&gt; &lt;mx:VBox width="100%" height="100%" label="Standard Page"&gt; &lt;mx:Label text="Standard Page Title" fontWeight="bold"/&gt; &lt;mx:Text width="100%" height="100%" text="Here is some page content." /&gt; &lt;/mx:VBox&gt; &lt;mx:VBox width="100%" height="100%" label="Image Gallery"&gt; &lt;mx:Label text="Image Gallery Title" fontWeight="bold" /&gt; &lt;mx:TileList width="100%" height="100%"&gt; &lt;mx:Image source="my_image1.png" /&gt; &lt;mx:Image source="my_image2.png" /&gt; &lt;mx:Image source="my_image3.png" /&gt; &lt;mx:Image source="my_image4.png" /&gt; &lt;/mx:TileList&gt; &lt;/mx:VBox&gt; &lt;/mx:TabNavigator&gt; &lt;/mx:Application&gt; </code></pre> <p>You can stack as many child container components within the <code>TabNavigator</code> as you like, and their contents will (by default) only be loaded when you select the relevant tab.</p> <p>If you can be a little more specific about what you're trying to build, there's probably a few more tricks for you out there too. Hopefully this gives you a start though.</p> <p><strong>EDIT:</strong> Okay, if you're using dropdown menus instead, it's the same concept but a little more manual labour is involved.</p> <p>The <code>TabNavigator</code> component uses a <code>ViewStack</code> component (<a href="http://livedocs.adobe.com/flex/3/html/navigators_3.html" rel="nofollow noreferrer">Adobe docs</a>), which is basically a stack of content pages where only one is shown at a time (determined by the stack's <code>selectedIndex</code> property), with a <code>TabBar</code> component to control the selected index. What you want to do is still use that same ViewStack to hold all your pages, but you want a dropdown menu item selection to change the selectedIndex for you.</p> <p>A <code>MenuBar</code> component (<a href="http://livedocs.adobe.com/flex/3/html/help.html?content=menucontrols_6.html" rel="nofollow noreferrer">Adobe docs</a>) provides the dropdown items, generated from an XMLListCollection data provider. To handle item selections, set an <code>itemClick</code> event handler to the MenuBar, and set the ViewStack's selectedIndex property based on which menu item was selected.</p> <p>Something like this should give you a start, and hopefully the comments help explain it. From there you can add pages, MenuBar items, etc.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"&gt; &lt;mx:Script&gt; &lt;![CDATA[ import mx.events.MenuEvent; /** * Handle the selection of a menu item. */ private function menuItemClickHandler(event:MenuEvent):void { // Get the submenuitem node that was clicked var selection:XML = XML(event.item); // Depending on the label of the item that was clicked, // modify the selectedIndex property of the content ViewStack switch(selection.@label.toString()) { case "Page 1": pageStack.selectedIndex = 0; break; case "Page 2": pageStack.selectedIndex = 1; break } } ]]&gt; &lt;/mx:Script&gt; &lt;!-- Data provider collection for the menu bar --&gt; &lt;mx:XMLListCollection id="menuXLC"&gt; &lt;mx:source&gt; &lt;mx:XMLList&gt; &lt;menuitem label="Content"&gt; &lt;submenuitem label="Page 1" /&gt; &lt;submenuitem label="Page 2" /&gt; &lt;/menuitem&gt; &lt;/mx:XMLList&gt; &lt;/mx:source&gt; &lt;/mx:XMLListCollection&gt; &lt;!-- MenuBar to provide dropdown items --&gt; &lt;mx:MenuBar dataProvider="{menuXLC}" width="100%" labelField="@label" itemClick="menuItemClickHandler(event)" /&gt; &lt;!-- ViewStack containing the various content pages --&gt; &lt;mx:ViewStack id="pageStack" width="100%" height="100%"&gt; &lt;!-- Each of these child components represents a separate page of content. You should really define them in separate components. --&gt; &lt;mx:VBox id="contentPageOne" label="First Page" width="100%" height="100%"&gt; &lt;mx:Label text="First Page Title" /&gt; &lt;mx:Text text="First Page content." /&gt; &lt;/mx:VBox&gt; &lt;mx:VBox id="contentPageTwo" label="Second Page" width="100%" height="100%"&gt; &lt;mx:Label text="Second Page Title" /&gt; &lt;mx:Text text="Second Page content." /&gt; &lt;/mx:VBox&gt; &lt;/mx:ViewStack&gt; &lt;/mx:Application&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload