Flex中如何在TabBar控件中添加图标(icons)的例子
By Minidxer | July 29, 2008
和前面的Flex中给TabNavigator控件增加Icons图标的例子类似的,接下来的例子演示了Flex中如何在TabBar控件中添加图标(icons)。
让我们先来看一下Demo(可以右键View Source或点击这里察看源代码):
下面是完整实现代码(或点击这里察看):
Download: main.mxml
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="vertical"
- verticalAlign="middle"
- backgroundColor="white">
- <mx:Script>
- <![CDATA[
- [Bindable]
- [Embed(source="assets/bulletCheck.png")]
- private var BulletCheck:Class;
- [Bindable]
- [Embed(source="assets/bulletWarning.png")]
- private var BulletWarning:Class;
- [Bindable]
- [Embed(source="assets/bulletCritical.png")]
- private var BulletCritical:Class;
- ]]>
- </mx:Script>
- <mx:VBox id="box" width="400" verticalGap="0">
- <mx:TabBar id="tabBar"
- direction="horizontal"
- dataProvider="{viewStack}"
- width="100%" />
- <mx:ViewStack id="viewStack"
- width="100%"
- height="100"
- backgroundColor="white"
- borderSides="left bottom right"
- borderStyle="solid"
- borderThickness="1">
- <mx:Canvas id="child1"
- label="Success"
- icon="{BulletCheck}">
- <mx:Label text="one" />
- </mx:Canvas>
- <mx:Canvas id="child2"
- label="Warning"
- icon="{BulletWarning}">
- <mx:Label text="two" />
- </mx:Canvas>
- <mx:Canvas id="child3"
- label="Error"
- icon="{BulletCritical}">
- <mx:Label text="three" />
- </mx:Canvas>
- </mx:ViewStack>
- </mx:VBox>
- </mx:Application>
代码:Peter deHaan 翻译/整理/编译:minidxer