Adobe
产品
Acrobat
Creative Cloud
创意套装
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
更多产品
解决方案
数字营销
数字媒体
教育
金融服务业
政府部门
网页体验管理
更多解决方案
学习帮助下载公司
商店
在线商店
批量许可
查找经销商
搜索
 
信息 登录
欢迎,我的支持
我的帐户
注销
为何登录?登录后可以管理您的帐户,访问试用版下载、产品扩展和社区区域等。
Adobe
产品 分类 购买   搜索  
解決方案 公司
学习
登录 注销 我的货物 我的支持
Date Date
Qty:
Subtotal
Checkout
Adobe 开发者中心 / Flex 开发人员中心 / Flex 快速入门 /

Using containers

by Adobe

Adobe logo

Created

22 March 2010

页面工具

在 Facebook 上共享
在 Twitter 上共享
在 LinkedIn 上共享
书签
打印

Tags

要求

用户级别

全部

必需产品

  • Flex (Download trial)

A container defines a rectangular region of the drawing surface of the Adobe Flash Player. Within a container, you define the components, both controls and containers, that you want to appear within the container. Components defined within a container are called children of the container. Adobe Flex provides a wide variety of containers, ranging from simple boxes through panels and forms, to elements such as accordions or tabbed navigators that provide built-in navigation among child containers.

The Spark namespace provides the following containers: Application, Panel, BorderContainer, Group, and others. You can choose a layout algorithm with Spark containers, as shown in the QuickStart examples. Spark containers contain a controlBarContent property that you can use to define a control bar and its contents for the container.

The MX namespace provides the following containers: Canvas, HBox, VBox, HDividedBox, and others. The layout algorithm of MX containers is fixed, and cannot be changed.

At the root of a Flex application is a single container, the <s:Application> container, that represents the entire Flash Player drawing surface. This Application container holds all other containers and components.

Tip: Many MX containers have equivalent containers in Spark. Adobe recommends that you use Spark containers when available. For more information, see Introduction to containers in the Adobe Flex 4 Help.

This article covers:

  • Using layout containers
  • Using navigators

Using layout containers

You use layout containers for laying out a user interface. The following table describes the layout containers that the following example uses:

  Name Description
Panel

<s:Panel>

The Panel container displays a title bar, a caption, a border, and its children.

BorderContainer

<s:BorderContainer>

The BorderContainer container provides a set of CSS styles and class properties to control the border and background of the container.

SkinnableContainer

<s:SkinnableContainer>

You can customize the appearance of a SkinnableContainer container using skins.

Group

<s:Group>

Use the Group container when you want to manage visual and graphical components.

HDividedBox

<mx:HDividedBox>

The HDividedBox container lays out the child components horizontally, much like a HBox container, except that it inserts an adjustable divider between the children. The VDividedBox container lays out the child components vertically, and also inserts an adjustable divider between the children.

Tile

<mx:Tile>

The Tile container arranges its children in multiple rows or columns.

Form Icon

<mx:Form>

The Form container arranges its children in a standard form format.

Additionally, the example uses the Spacer control, which is not a container, to aid in the layout of the interface.

Tip: The Spacer control is an invisible control that is used for precise positioning of elements inside automatically positioned containers. In this example, the Spacer control is the percentage-based component in the Application control bar. Flex sizes the Spacer control to occupy all available space that is not required for other components.

Example

<?xml version="1.0" encoding="utf-8"?> <!-- Layoutcontainers.mxml --> <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="525" height="400"> <s:layout> <s:VerticalLayout paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10" horizontalAlign="center"/> </s:layout> <s:controlBarContent> <s:Label text="ApplicationControlBar" fontFamily="Verdana" fontWeight="bold" fontSize="12"/> <mx:Spacer width="100%"/> <s:Button label="Log out"/> </s:controlBarContent> <s:Panel title="Panel" width="90%" height="90%"> <s:layout> <s:HorizontalLayout paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10"/> </s:layout> <s:controlBarContent> <s:Label text="ControlBar in Panel" fontWeight="bold"/> <mx:Spacer width="100%"/> <s:Button label="Previous"/> <s:Button label="Finish"/> </s:controlBarContent> <mx:HDividedBox width="100%" height="100%"> <s:BorderContainer width="100%" height="100%" borderStyle="solid" > <s:layout> <s:VerticalLayout paddingBottom="5" paddingLeft="5" paddingRight="5" paddingTop="5" clipAndEnableScrolling="true"/> </s:layout> <s:Label text="BorderContainer" fontWeight="bold"/> <mx:Form> <mx:FormHeading label="First form" /> <mx:FormItem label="Name"> <s:TextInput width="100%" /> </mx:FormItem> </mx:Form> </s:BorderContainer> <s:BorderContainer width="100%" height="100%" borderStyle="solid"> <s:layout> <s:VerticalLayout paddingBottom="5" paddingLeft="5" paddingRight="5" paddingTop="5" clipAndEnableScrolling="true"/> </s:layout> <s:Label text="BorderContainer" fontWeight="bold"/> <mx:Form> <mx:FormHeading label="Second form" /> <mx:FormItem label="Name"> <s:TextInput width="100%" /> </mx:FormItem> <mx:FormItem label="Email"> <s:TextInput width="100%" /> </mx:FormItem> </mx:Form> </s:BorderContainer> </mx:HDividedBox> </s:Panel> </s:Application>

Result

缺少 Flash player 您必须装有 Flash 10? 您必须装有 Flash 10?

Back to top

Using navigation containers

Navigator containers control user movement, or navigation, among multiple children where the children are other containers.

The direct children of a navigator container must be containers, either layout or navigator containers. You cannot directly nest a control within a navigator; controls must be children of a child container of the navigator container.

The following examples uses a <s:ButtonBar>, <mx:LinkBar>, and <s:TabBar> to change the content of the ViewStack navigator container

The following table describes the navigator containers that the following example uses:

  Name Description
Panel

<mx:Accordion>

The Accordion container defines a sequence of child panels, but displays only one panel at a time. To navigate a container, the user clicks the navigation button that corresponds to the child panel that they want to access. Accordion containers let users access the child panels in any order to move back and forth through the form.

HDividedBox

<mx:TabNavigator>

A TabNavigator container creates and manages a set of tabs, which you use to navigate among its children. The children of a TabNavigator container are other containers. The TabNavigator container creates one tab for each child. When the user selects a tab, the TabNavigator container displays the associated child.

Tile

<mx:ViewStack>

A ViewStack navigator container is made up of a collection of child containers that are stacked on top of each other, with only one container visible, or active, at a time. The ViewStack container does not define a built-in mechanism for users to switch the currently active container; you must use a LinkBar, TabBar, ButtonBar, or ToggleButtonBar control or build the logic yourself in ActionScript to let users change the currently active child.

Example

<?xml version="1.0" encoding="utf-8"?> <!-- NavigationContainers.mxml --> <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="550" height="550"><s:Panel left="10" top="10" right="10" bottom="10" title="Navigators"> <mx:Accordion width="47.5%" height="200" top="36" left="10"> <mx:Canvas label="Navigation button 1" width="100%" height="100%"> <s:Label x="10" y="10" text="Contents 1"/> </mx:Canvas> <mx:Canvas label="Navigation button 2" width="100%" height="100%"> <s:Label x="10" y="10" text="Contents 2"/> </mx:Canvas> <mx:Canvas label="Navigation button 3" width="100%" height="100%"> <s:Label x="10" y="10" text="Contents 3"/> </mx:Canvas> </mx:Accordion> <mx:TabNavigator right="10" width="47.5%" height="200" y="36"> <mx:Canvas label="Tab 1" width="100%" height="100%"> <s:Label x="10" y="10" text="Contents 1"/> </mx:Canvas> <mx:Canvas label="Tab 2" width="100%" height="100%"> <s:Label x="10" y="10" text="Contents 2"/> </mx:Canvas> <mx:Canvas label="Tab 3" width="100%" height="100%"> <s:Label x="10" y="10" text="Contents 3"/> </mx:Canvas> </mx:TabNavigator> <mx:ViewStack id="myViewStack" width="47.5%" height="200" right="10" bottom="10" borderColor="#000000" borderStyle="solid"> <mx:Canvas label="View 1" width="100%" height="100%"> <s:Label x="10" y="10" text="Contents 1"/> </mx:Canvas> <mx:Canvas label="View 2" width="100%" height="100%"> <s:Label x="10" y="10" text="Contents 2"/> </mx:Canvas> <mx:Canvas label="View 3" width="100%" height="100%"> <s:Label x="10" y="10" text="Contents 3"/> </mx:Canvas> </mx:ViewStack> <!-- Labels for the various controls --> <s:Label x="10" y="275" text="ButtonBar"/> <s:Label x="10" y="10" text="Accordion"/> <s:Label x="263" y="10" text="TabNavigator"/> <s:Label x="276" y="270" text="ViewStack"/> <s:Label x="10" y="337" text="LinkBar"/> <s:Label x="10" y="406" text="TabBar"/> <!-- All these navigators use the same dataProvider, namely, the myViewStack ViewStack instance. Changing the selected view in one will affect all the others also. --> <s:ButtonBar x="10" y="291" dataProvider="{myViewStack}" /> <mx:LinkBar x="10" y="353" dataProvider="{myViewStack}" /> <mx:TabBar x="10" y="422" dataProvider="{myViewStack}" /> </s:Panel> </s:Application>

Result

缺少 Flash player 您必须装有 Flash 10? 您必须装有 Flash 10?

Back to top

For more information

  • Introduction to Containers
  • Application Containers
  • Spark Containers
  • MX Layout Containers
  • MX Navigator Containers

Back to top


This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 Unported License.

产品

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • 移动应用程序
  • Photoshop
  • Touch Apps

解决方案

  • 数字营销
  • 数字媒体
  • 网页体验管理

行业

  • 教育
  • 金融服务业
  • 政府部门

帮助

  • 产品帮助中心
  • 订货和退货
  • 下载和安装
  • 我的 Adobe

学习

  • Adobe 开发人员连接
  • Adobe TV
  • 培训和认证
  • 论坛
  • 设计中心

购买方式

  • 在线商店
  • 批量许可
  • 查找经销商

下载

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

公司

  • 新闻编辑室
  • 合作伙伴计划
  • 公司社会责任
  • 工作机会
  • 投资者关系
  • 事件
  • 法律
  • 安全
  • 联系 Adobe
选择您的地区 中国(更改)
选择您的地区 关闭

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.

使用条款 | 隐私政策和 Cookies (更新)

京 ICP 备 10217899 号 京公网安备 110105010404