使用外部 CSS 来设置 Flash MX 2004 组件外观

类别:编程语言 点击:0 评论:0 推荐:

While working on a project at Schematic, I was investigating the possibility of defining style attributes for component instances in an external CSS file. I got the following system to work:

1. Create an external CSS file, defining the style(s) and component-specific styles you want to customize. For example:

/* Filename: styles.css */
checkbox {
 color: 0x0000FF;
 embedFonts: false;
 fontFamily: Arial;
 fontSize: 24;
}

2. Load the style sheet into your Flash movie, retrieve the style name, and apply it to your instance:

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");

--From (http://blogs.flashsupport.com/robert/archive/2004/09/08/209.aspx)

本文地址:http://com.8s8s.com/it/it26368.htm