-
Notifications
You must be signed in to change notification settings - Fork 13
Description
I am trying to combine FCSS with Spark Skins - idea from here: http://seanhess.net/posts/flex_skins_and_styles. I want to use FCSS instead of Flex CSS.
The idea is the host component exposes a style property, which returns an IStyle cast as an Object, since you cannot bind to dynamic properties on an interface:
private var _style:IStyle;
[Bindable]
public function get style():Object
{
return _style;
}
public function set style(value:Object):void
{
_style = value as IStyle;
}
Next, in the spark skin class, you could code something like this:
<mx:Image
id="icon"
color.disabled="{hostComponent.style.colorDisabled}"
color.down="{hostComponent.style.colorDown}"
color.up="{hostComponent.style.colorUp}"
color.over="{hostComponent.style.colorOver}"/>
Two problems I encountered:
-
The binding does not work because Style is not an EventDispatcher. IStyle should extend IEventDispatcher, and Stye or AbstractOrderedObject should implement IEventDispatcher, and raise a PropertyChangeEvent when a property changes.
-
In my CSS, I would prefer to create style properties with dashes, e.g., "color-up". However, I cannot refer to the dynamic property on Style, except by using brackets (style['color-up']) which are not allowed in binding expressions. It would be great if FCSS converted "color-up" in my CSS to a "colorUp" property on the Style, which is pretty much how Flex CSS and HTML CSS work (e.g., "font-family" in CSS and "fontFamily" in JS or AS). Then I could say use style.colorUp in a binding expression.
Spark skinning appears to be the immediate future of Flex programming, but I want to be able to style my skins, and I think I could use FCSS to accomplish this if the above changes were made. Maybe this is not what FCSS was intended for, but I think it could work.