incubator-flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Left Right <>
Subject Framework: what do I need to do to initialize styles
Date Wed, 11 Apr 2012 15:57:57 GMT

I've been trying to create a light-weight application class substitute for
use in AS only. I could extend SystemManager and (seemingly) implement all
needed functions (that would be generated otherwise). I also created a
class with a mixin function to initiate styles (basically copied from a
working example).
My "application" class extends SpriteVisualElement. I want it to be that
way because my goal is to decouple all sorts of managers globals and such
from this class (and create more specific application classes for different
kinds of projects). All runs fine until I need to add a framework visual
component to the display list. The problem occurs in commitProperties - the
component can't find it's skin.
I tried to chime into what StyleManager does and by doing something like:

button.moduleFactory = this;
button.setStyle("skinClass", ButtonSkin);
button.setStyle("justificationStyle", "prioritizeLeastAdjustment");

I could get the button's skin resolved, for this button... but not for it's
label. I can't reach to the label's styles from Application class or any
other class in my disposal unless I modify Button class (I don't want to do
that at the moment - the idea is to get something basic working with what
already exists).
Notice that I've added justificationStyle - this would be technically a bug
in framework, where it tries to assign null to a property that can't accept
nulls, but it's a very minor thing in comparison to the rest of the code,
so just don't focus on it. This is only to show you the extent I could
advance trying to solve the issue.

My style initiating code looks like this:

// Application
UIComponentGlobals.layoutManager = LayoutManager.getInstance();
UIComponentGlobals.layoutManager.usePhasedInstantiation = true;

// _Application_Style
    public static function init(fbs:IFlexModuleFactory):void
        var styleManager:IStyleManager2 =
fbs.getImplementation("mx.styles::IStyleManager2") as IStyleManager2;

        var conditions:Array = null;
        var condition:CSSCondition = null;
        var selector:CSSSelector = null;
        var style:CSSStyleDeclaration;
        var effects:Array;

        var mergedStyle:CSSStyleDeclaration;

        // spark.components.Button
        selector = null;
        conditions = null;
        conditions = null;
        selector = new CSSSelector("spark.components.Button", conditions,
        mergedStyle =
        style = new CSSStyleDeclaration(selector, styleManager, mergedStyle
== null);

        if (style.defaultFactory == null)
            style.defaultFactory = function():void
                this.skinClass = spark.skins.spark.ButtonSkin;

        if (mergedStyle != null &&
            (mergedStyle.defaultFactory == null ||
   style.defaultFactory(), new

styleManager.setStyleDeclaration(style.mx_internal::selectorString, style,
<<<< the above piece of code is repeated many-many times for each component
var styleNames:Array = ["lineHeight", ...
<<<< usually generated in FlexInit >>>> "typographicCase"];
 for (var i:int = 0; i < styleNames.length; i++)
<<<< originally from Application class >>>>

Can, anyone, please, enlighten me, I seem to be missing some key
requirement for the style manager to initiate. Is there some manual switch
I could start the manager myself, rather than from generated code? I've
been searching for it for two days, and I don't want to talk about poor
quality of code because it only offends people :) but I couldn't help
mentioning it. But I do mention it all the time, so, that wouldn't be new
to you :)

Anyways, all help welcome.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message