使用外部 CSS 來設定 Flash MX 2004 組件外觀

來源:互聯網
上載者:User
css

  編者註:我們都知道可以輕鬆的設定 Flash MX 2004 組件的外觀,但是如果能用一個外部的 CSS 檔案來控制,豈不是更好,使用起來就會更加的方便。這裡是在網上發現的一個例子(原文網址: http://blogs.flashsupport.com/robert/archive/2004/09/08/209.aspx ):

  1. 建立一個 CSS 檔案,定義組件的一些屬性,如: /* Filename: styles.css */

checkbox {   color: 0x0000FF;   embedFonts: false;   fontFamily: Arial;  fontSize: 24; } 

  2. 在 Flash 中載入這個 CSS 檔案,將組件套上相關的樣式:

import mx.controls.CheckBox;   var oStyle:Object;   var ccbTest:mx.controls.CheckBox;   var styles = new TextField.StyleSheet();   styles.onLoad = function(bSuccess:Boolean):Void {    if (bSucess) {       oStyle = this.getStyle("checkbox");       for(var i in oStyle){         ccbTest.setStyle(i, oStyle[i]);       }     } else {     trace("Error loading CSS file.");   } }; styles.load("styles.css"); 


相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.