雷火电竞-中国电竞赛事及体育赛事平台

歡迎來(lái)到入門教程網(wǎng)!

Flex

當(dāng)前位置:主頁(yè) > 網(wǎng)絡(luò)編程 > Flex >

Flex中TabNavigator設(shè)置Tabs樣式思路及源碼

來(lái)源:本站原創(chuàng)|時(shí)間:2020-01-11|欄目:Flex|點(diǎn)擊:

1、設(shè)計(jì)思路

(1)設(shè)計(jì)一個(gè)TabNavigator,其中包含兩個(gè)Tabs;

(2)設(shè)置Tabs樣式

2、設(shè)計(jì)源碼

Tabs.mxml:

復(fù)制代碼 代碼如下:

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

<!-- Define custom Strokes for the columns. -->
<mx:SolidColorStroke id="s1" color="0xADFF2F" weight="2"/>
<mx:SolidColorStroke id="s2" 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]
//學(xué)生數(shù)據(jù)綁定
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]
//教師數(shù)據(jù)綁定
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 width="100%" height="100%" paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10">
<mx:TabNavigator width="100%" height="100%" fontSize="12" cornerRadius="8">
<s:NavigatorContent label="學(xué)生" width="100%" height="100%">
<mx:VBox width="100%" height="100%" paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10">
<mx:ColumnChart id="column" dataProvider="{studentArray}" showDataTips="true" width="100%" height="100%" fontSize="12">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="sno" displayName="學(xué)號(hào)"/>
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries displayName="數(shù)學(xué)成績(jī)" xField="sno" yField="math" fill="{sc1}" stroke="{s1}"/>
</mx:series>
</mx:ColumnChart>
<mx:HBox width="100%" height="30">
<s:Label width="50%"/>
<mx:Legend dataProvider="{column}"/>
</mx:HBox>
</mx:VBox>

</s:NavigatorContent>
<s:NavigatorContent label="教師" width="100%" height="100%" fontSize="12">
<mx:VBox width="100%" height="100%" paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10">
<mx:ColumnChart id="column1" dataProvider="{teacherArray}" showDataTips="true" width="100%" height="100%" fontSize="12">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="tno" displayName="工號(hào)"/>
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries displayName="教師評(píng)分" xField="tno" yField="tscore" fill="{sc2}" stroke="{s2}"/>
</mx:series>
</mx:ColumnChart>
<mx:HBox width="100%" height="30">
<s:Label width="50%"/>
<mx:Legend dataProvider="{column1}"/>
</mx:HBox>
</mx:VBox>
</s:NavigatorContent>
</mx:TabNavigator>
</mx:VBox>
</s:Application>

3、設(shè)計(jì)說(shuō)明

(1)tab-style-name:設(shè)置所有tabs的樣式類

(2)first-tab-style-name:設(shè)置第一個(gè)tabs的樣式類

(3)last-tab-style-name:設(shè)置最后一個(gè)tabs的樣式類

(4)selected-tab-text-style-name:設(shè)置選中的tabs中的text樣式類

4、設(shè)計(jì)結(jié)果

(1)初始化時(shí)結(jié)果
 
(2)切換tabs

上一篇:Flex打開(kāi)新窗口將主窗口數(shù)據(jù)傳給子窗口然后返回

欄    目:Flex

下一篇:Flex中通過(guò)RadioButton進(jìn)行切換示例代碼

本文標(biāo)題:Flex中TabNavigator設(shè)置Tabs樣式思路及源碼

本文地址:http://www.jygsgssxh.com/a1/Flex/11594.html

網(wǎng)頁(yè)制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語(yǔ)言數(shù)據(jù)庫(kù)服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有