Adobe
Products
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
Student and Teacher Editions
More products
Solutions
Digital marketing
Digital media
Education
Financial services
Government
Web Experience Management
More solutions
Learning Help Downloads Company
Buy
Home use for personal and home office
Education for students, educators, and staff
Business for small and medium businesses
Licensing programs for businesses, schools, and government
Special offers
Search
 
Info Sign in
Welcome,
My cart
My orders My Adobe
My Adobe
My orders
My information
My preferences
My products and services
Sign out
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out My orders My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Review and Checkout
Adobe Developer Connection / Flex Developer Center / Flex in a Week /

Exercise 4.6: Navigating using navigator containers

by Trilemetry

Trilemetry
  • Trilemetry, Inc.

Content

  • Create an Accordion container
  • Use a TabNavigator container
  • Use a ViewStack container
  • Use the TabBar control
  • Use a LinkBar control
  • Use a ButtonBar control

Created

23 May 2011

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
Flash Builder Flex RIA

Requirements

Prerequisite knowledge

  • Exercise 1.1: Setting up Flash Builder and your project files

User level

Beginning

Required products

  • Flash Builder 4.5 Premium (Download trial)

Sample files

  • ex4_06_starter.zip
  • ex4_06_solution.zip

In this exercise you will use multiple navigator containers to display the content shown in Figure 1.

This is the finished application.
Figure 1. This is the finished application.

In this exercise, you will learn how to:

  • Use an Accordion navigator container
  • Use a TabNavigator navigator container
  • Use a ViewStack navigator container
  • Use a TabBar navigator control
  • Use a LinkBar navigator control
  • Use a ButtonBar control

Create an Accordion container

In this section you will create an Accordion container to display employee information.

  1. Download the ex4_06_starter.zip file if you haven't done so already and extract the file ex4_06_starter.fxp to your computer.
  2. Open Flash Builder.
  3. Import the ex4_06_starter.fxp file.
  4. Within the Package Explorer view, expand the components folder to show the HumanResources, InfomationTechnology, and Marketing MXML components (see Figure 2.)
View the components directory.
Figure 2. View the components directory.
  1. Open ex4_06_starter.mxml.
  2. Run the file.

    The components are displayed vertically (see Figure 3).

Figure 3. See the components are displayed vertically.
  1. Return to Flash Builder.
  2. Locate the UI components comment.
  3. Below the last component, create an Accordion container.
<components:InformationTechnology label="Information Technology" /> <mx:Accordion> </mx:Accordion>
  1. Move the component instances inside the Accordion container.
<mx:Accordion> <components:HumanResources label="Human Resources" /> <components:Marketing label="Marketing" /> <components:InformationTechnology label="Information Technology" /> </mx:Accordion>
  1. Save the file and run the application.

    The components are now listed in an Accordion container, but note that the employees are not contained within the container. (see Figure 4).

Note that the content is not contained within the Accordion container.
Figure 4. Note that the content is not contained within the Accordion container.

Next, you will use the resizeToContent property to assure the employee content is visible.

  1. Return to Flash Builder.
  2. To the Accordion container, add the resizeToContent property set to true.
<mx:Accordion resizeToContent="true"> ... </mx:Accordion>
  1. Save the file and run the application.
  2. Click through the tabs.

    Notice that each pane resizes to fit all of the components (see Figure 5).

Note that the containers resize to fit all of the components.
Figure 5. Note that the containers resize to fit all of the components.

Use a TabNavigator container

In this section you will replace the Accordion container with a TabNavigator container.

  1. Return to Flash Builder.
  2. Change the Accordion container into a TabNavigator container. Remember to change both the opening and closing tags.
<mx:TabNavigator resizeToContent="true"> <components:HumanResources label="Human Resources" /> ... </mx:TabNavigator>
  1. Save the file and run the application.

    You should see a TabNavigator container interface (see Figure 6).

You should see the TabNavigator container.
Figure 6. You should see the TabNavigator container.

Use a ViewStack container

In this section you will create a ViewStack container to display employee information.

  1. Return to Flash Builder.
  2. Change the TabNavigator container into a ViewStack container. Remember to change both the opening and closing tags.
<mx:ViewStack resizeToContent="true"> <components:HumanResources label="Human Resources" /> ... </mx:ViewStack>
  1. Save the file and run the application.

    Note that only the content of the first child container is displayed by default in the ViewStack container (see Figure 7).

Only the content of the first child conainer in the ViewStack container is visible.
Figure 7. Only the content of the first child conainer in the ViewStack container is visible.

Use the TabBar control

In this section you will use a TabBar control to switch between components in the control.

  1. To the ViewStack container, add the id property set to employeeDepartments.
<mx:ViewStack id="employeeDepartments" resizeToContent="true"> <components:HumanResources label="Human Resources" /> ...
  1. Above the ViewStack container, create a Spark TabBar control.
<s:TabBar/> <mx:ViewStack id="employeeDepartments" resizeToContent="true"> ...
  1. To the TabBar control, add the dataProvider property with a value that is bound to the content in the employeeDepartments ViewStack container.
<s:TabBar dataProvider="{employeeDepartments}"/>
  1. Save the file and run the application.
  2. Click through the tabs (see Figure 8).
Figure 8. Click the TabBar to change components.

Use a LinkBar control

In this section you will replace the TabBar control with a LinkBar control.

  1. Return to Flash Builder.
  2. Change the TabBar control into a LinkBar control.
<mx:LinkBar dataProvider="{employeeDepartments}"/>
  1. Save the file and run the application.

    The application now uses a LinkBar control to switch between components in the ViewStack container (see Figure 9).

Figure 9. Run the application to see it now uses a LinkBar control.

Use a ButtonBar control

In this section, you will use a ButtonBar control toswitch between components in the control.

  1. Return to Flash Builder.
  2. Change the LinkBar control into a Spark ButtonBar control.
<s:ButtonBar dataProvider="{employeeDepartments}"/>
  1. Save the file and run the application.

    The application now uses a ButtonBar control to switch betweencomponents in the ViewStack container (see Figure 10).

Run the application to see it now uses the ButtonBar control.
Figure 10. Run the application to see it now uses the ButtonBar control.

In this exercise you used multiple navigator containers to display the content shown in Figure 10. In the next exercise you will use Flash Builder to create a login page.

Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License+Adobe Commercial Rights

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

More Like This

  • Exercise 4.7: Creating and navigating application states
  • Exercise 4.8: Creating a scalable user interface
  • Exercise 4.9: Animating components with effects
  • Exercise 3.5: Using formatters
  • Exercise 3.6: Validating form data
  • Exercise 3.7: Using two-way binding
  • Exercise 3.8: Creating a master/detail interface with a wizard
  • Exercise 4.10: Applying transitions to view states
  • Exercise 4.1: Passing data to item renderers for display
  • Exercise 4.2: Displaying dynamic data in a custom item renderer

Products

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • Mobile Apps
  • Photoshop
  • Touch Apps
  • Student and Teacher Editions

Solutions

  • Digital marketing
  • Digital media
  • Web Experience Management

Industries

  • Education
  • Financial services
  • Government

Help

  • Product help centers
  • Orders and returns
  • Downloading and installing
  • My Adobe

Learning

  • Adobe Developer Connection
  • Adobe TV
  • Training and certification
  • Forums
  • Design Center

Ways to buy

  • For personal and home office
  • For students, educators, and staff
  • For small and medium businesses
  • For businesses, schools, and government
  • Special offers

Downloads

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2012 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy Policy and Cookies (Updated)

Ad Choices

Reviewed by TRUSTe: site privacy statement