|
FlashMX2004自帶的組件比MX漂亮了很多, 但有時候為了讓組件的外觀和整個頁面的樣式相統一,
必須重新改變組件的外觀, 比如組件標籤的字體和顏色, 組件的背景顏色等等. 這個FlashMX自身
是做不到的. 改變組件外觀有三種方法: Use the Styles API(使用樣式API), Apply a theme
(應用一個主題名), 和Modify or replace a component's skins(修改或替換組皮膚). 這裡
著重說明第一種方法, Use the Styles API(application programming interface). 我們
可以利用Styles API 提供的屬性和方法( setStyle()和getStyle())來改變組件的顏色和文本
格式.其中使用Styles又有四種方法:
1.Set styles on a component instance. (對一個組件實例設置樣式) 2.Use the _global style declaration that sets styles for all components in a
document. (使用全局樣式聲明對文檔的所有組件設置樣式) 3.Create custom style declarations and apply them to specific component instances. (創建自定義樣式聲明並應用到指定的組件實例) 4.Create default class style declarations.(為組件類別創建樣式聲明)
下面對每一種方法進行詳解. Set styles on a component instance (對一個組件實例設置樣式).
從components面板拖個Button 組件到場景(也可以用其它組件),並命名為」myBtn」:
快捷鍵」F9」打開Action面板,在時間線上寫Action:
myBtn.setStyle("themeColor", "0x00CCFF"); myBtn.setStyle("fontFamily", "Verdana"); myBtn.setStyle("fontSize", "10"); myBtn.setStyle("fontWeight", "bold"); myBtn.setStyle("color", "0x990000");
|