设为首页 - 加入收藏 大连站长网 (https://www.0411zz.cn)- 大型站长资讯类网站,站长百科,建站经验,电子商务,云计算!
热搜: 公开 隔空手势
当前位置: 首页 > 服务器 > 搭建环境 > Unix > 正文

Flex中TabNavigator设置Tabs样式思路及源码

发布时间:2021-05-12 13:46 所属栏目:[Unix] 来源:站长网
导读:1、设计思路 (1)设计一个TabNavigator,其中包含两个Tabs; (2)设置Tabs样式 2、设计源码 Tabs.mxml: 复制代码 代码如下: ?xml version="1.0" encoding="utf-8"? s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe
1、设计思路

(1)设计一个TabNavigator,其中包含两个Tabs;

(2)设置Tabs样式

2、设计源码

Tabs.mxml:

复制代码 代码如下:


<?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="100%"
>
<fx:Declarations>
<!-- Define custom colors for use as fills. -->
<mx:SolidColor color="0xADFF2F" alpha=".8"/>
<mx:SolidColor color="0xADD8E6" alpha=".6"/>

<!-- Define custom Strokes for the columns. -->
<mx:SolidColorStroke color="0xADFF2F" weight="2"/>
<mx:SolidColorStroke color="0xADD8E6" weight="2"/>
</fx:Declarations>

<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
.myTabs{
color:#FFFFFF;
font-weight:bold;
background-color:#6495ED;
}
.myTextTabs{
color:#8B0000;
background-color:#97FFFF;
font-weight:bold;
}
mx|TabNavigator{
tab-style-name:"myTabs";
first-tab-style-name:"myTabs";
last-tab-style-name:"myTabs";
selected-tab-text-style-name:"myTextTabs";
}
</fx:Style>

<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;

[Bindable]
//学生数据绑定
private var studentArray:ArrayCollection = new ArrayCollection([
{sno:"2013010101",math:"96"},
{sno:"2013010102",math:"89"},
{sno:"2013010103",math:"87"},
{sno:"2013010104",math:"90"},
{sno:"2013010105",math:"78"},
{sno:"2013010106",math:"69"},
{sno:"2013010107",math:"92"},
{sno:"2013010108",math:"80"},
{sno:"2013010109",math:"60"},
{sno:"2013010110",math:"89"}
]);

[Bindable]
//教师数据绑定
private var teacherArray:ArrayCollection = new ArrayCollection([
{tno:"2013010101",tscore:"96"},
{tno:"2013010102",tscore:"99"},
{tno:"2013010103",tscore:"77"},
{tno:"2013010104",tscore:"70"},
{tno:"2013010105",tscore:"98"},
{tno:"2013010106",tscore:"79"},
{tno:"2013010107",tscore:"82"},
{tno:"2013010108",tscore:"70"},
{tno:"2013010109",tscore:"80"},
{tno:"2013010110",tscore:"79"}
]);
]]>
</fx:Script>

<mx:VBox paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10">
<mx:TabNavigator fontSize="12" cornerRadius="8">
<s:NavigatorContent label="学生">
<mx:VBox paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10">
<mx:ColumnChart dataProvider="{studentArray}" showDataTips="true" fontSize="12">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="sno" displayName="学号"/>
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries displayName="数学成绩" xField="sno" yField="math" fill="{sc1}" stroke="{s1}"/>
</mx:series>
</mx:ColumnChart>
<mx:HBox>
<s:Label/>
<mx:Legend dataProvider="{column}"/>
</mx:HBox>
</mx:VBox>

</s:NavigatorContent>
<s:NavigatorContent label="教师" fontSize="12">
<mx:VBox paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10">
<mx:ColumnChart dataProvider="{teacherArray}" showDataTips="true" fontSize="12">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="tno" displayName="工号"/>
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries displayName="教师评分" xField="tno" yField="tscore" fill="{sc2}" stroke="{s2}"/>
</mx:series>
</mx:ColumnChart>
<mx:HBox>
<s:Label/>
<mx:Legend dataProvider="{column1}"/>
</mx:HBox>
</mx:VBox>
</s:NavigatorContent>
</mx:TabNavigator>
</mx:VBox>
</s:Application>


3、设计说明

(1)tab-style-name:设置所有tabs的样式类

(2)first-tab-style-name:设置第一个tabs的样式类

(3)last-tab-style-name:设置最后一个tabs的样式类

(4)selected-tab-text-style-name:设置选中的tabs中的text样式类

4、设计结果

(1)初始化时结果

Flex中TabNavigator设置Tabs样式思路及源码

 
(2)切换tabs

Flex中TabNavigator设置Tabs样式思路及源码

【免责声明】本站内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

推荐文章