预览效果.下面是这三个组件的前后效果对比图:
这种方法使得场景里的所有组件的外观保持一致.
create custom style declarations and apply them to specific component instances.
(创建自定义样式声明并应用到指定的组件实例)
当我们把组件拖到场景里便可以利用cssstyledeclaration 对象创建一个样式声明来改变指定组件的外观。
还是从components面板拖button,checkbox和radiobutton三个组件到场景并分别命名为
compa, compb, compc. 在时间线上写action:
//创建一个cssstyledeclaration对象实例
var styleobj = new mx.styles.cssstyledeclaration;
//设置stylename属性
styleobj.stylename = "newstyle";
//将样式放到全局样式列表
_global.styles.newstyle = styleobj;
//设置样式属性
styleobj.fontfamily = "verdana";
styleobj.fontsize = "10";
styleobj.fontweight = "bold";
styleobj.color = "0x990000";
styleobj.setstyle("themecolor", "0x00ccff");
//对组件设置样式
compa.setstyle("stylename", "newstyle");
compb.setstyle("stylename", "newstyle");
compc.setstyle("stylename", "newstyle");

