styleManager:使用setStyleDeclaration的问题

时间:2011-02-23 17:23:21

标签: flex actionscript-3 flex4 coding-style

嘿伙计们!! !! 我使用styleManager.setStyleDeclaration为同一组件的多个实例设置CssStyleDeclaration对象,该实例用于不同的画布。
我想在各种画布中设置这个组件的不同属性,但它不会发生,因为setStyleDeclaration接受组件的名称并将样式设置为全局,我猜想。
以下是第一个 cssstyledeclaration

this.dataTickerOddStyle = new CSSStyleDeclaration();
        this.dataTickerOddStyle.setStyle("fillColors", StringUtilEx.ExtractColorPair(o.DataTicker.Item[0].Background_Fill_Colors));
        this.dataTickerOddStyle.setStyle("fillAlphas", StringUtilEx.ExtractNumberPair(o.DataTicker.Item[0].Background_Fill_Alphas));
        this.dataTickerOddStyle.setStyle("gradientRatio", StringUtilEx.ExtractNumberPair(o.DataTicker.Item[0].Background_Gradient_Ratios));
        this.dataTickerOddStyle.setStyle("cornerRadius", int(o.DataTicker.Item[0].Background_Corner_Radius));
        this.dataTickerOddStyle.setStyle("borderColor", StringUtilEx.ConvertToColor(o.DataTicker.Item[0].Background_Border_Color));
        this.dataTickerOddStyle.setStyle("borderThickness", Number(o.DataTicker.Item[0].Background_Border_Thickness));<br>

这就是我使用它的方式:

this.styleManager.setStyleDeclaration("com.GradientCanvas",WidgetStylesheet.instance.dataTickerOddStyle, true);

和另一个 cssstyledeclaration 是:

this.m_zoneBackgroundStyle = new CSSStyleDeclaration();
        this.m_zoneBackgroundStyle.setStyle("fillAlphas", StringUtilEx.ExtractNumberPair(o["Background_Fill_Alphas"]));
        this.m_zoneBackgroundStyle.setStyle("fillColors", StringUtilEx.ExtractColorPair(o["Background_Fill_Colors"]));
        this.m_zoneBackgroundStyle.setStyle("gradientRatio", StringUtilEx.ExtractNumberPair(o["Background_Gradient_Ratios"]));
        this.m_zoneBackgroundStyle.setStyle("borderColor", StringUtilEx.ConvertToColor(o["Background_Border_Color"]));
        this.m_zoneBackgroundStyle.setStyle("borderThickness", Number(o["Background_Border_Thickness"]));
        this.m_zoneBackgroundStyle.setStyle("cornerRadius", Number(o["Background_Corner_Radius"]));

为此我使用以下内容:

this.fill.styleManager.setStyleDeclaration("com.GradientCanvas", AppStylesheet.instance.m_zoneBackgroundStyle, true);<br>

请注意,我正在使用相同的选择器/组件。请提前帮助我...提前付款

2 个答案:

答案 0 :(得分:0)

(不确定我完全理解你的目的......但是......)

您可以在单个组件实例上设置样式,而无需更改全局样式。

component.setStyle( ... ) 

而不是

CSSStyleDeclaration.setStyle( ... )

答案 1 :(得分:0)

我解决了这个问题。我之前使用的是Type Selector,而不是Class Selector