flex4中的StyleManager 不生效
Flex4中的StyleManager到底怎么用呢?为什么我们在使用的时候总是不生效?
在Flex3.0中改变样式方法:
StyleManager.getStyleDeclaration('Button').setStyle('fontSize',24);
但是在flex4就有警告。
那么,在Flex4中改变样式的正确方法是:
var newStyleDeclaration:CSSStyleDeclaration = new CSSStyleDeclaration("com.desinger.Line");
newStyleDeclaration.defaultFactory = function():void
{
leftMargin = 50;
rightMargin = 50;
}
FlexGlobals.topLevelApplication.styleManager.setSt yleDeclaration("com.desinger.Line", newStyleDeclaration, true);
其中"com.desinger.Line"是你的CSS选择器的名称,可以是常用的类型选择器如 Button { color: #FF0000 },也可以是以"."开头的类选择器,如".redButton { color: #FF0000 }"。
CSSStyleDeclaration 类表示一组 CSS 样式规则。
可使用 FlexGlobals.topLevelApplication.styleManager.getSt yle()、setStyle() 和 clearStyle() 方法获取、设置和清除 CSSStyleDeclaration 上的样式属性。
还可以使用 FlexGlobals.topLevelApplication.styleManager.setSt yleDeclaration() 方法在运行时创建和安装 CSSStyleDeclaration。
猜你喜欢
转载自xv680xv.iteye.com/blog/1572808
今日推荐
周排行