开发者

Flex 4 - CSS type selectors in MXML components

Does anybody know the reason why CSS type selectors cannot be used inside MXML components, and/or a trick to make it work?

I see absolutely no reason for a such simple functionnality not to be supported, and I'd really开发者_开发问答 like to understand.

After all I read about CSS in Flex 4 being so much better than in Flex 3, I find myself quite disapointed when I'm forced to repeat myself, addding the same parameter to all my buttons...

    <fx:Style>
        @namespace s "library://ns.adobe.com/flex/spark";
        .sampleStyle {   color: red;   }        
    </fx:Style>

    <s:Button label="1" styleName="sampleStyle"/>
    <s:Button label="2" styleName="sampleStyle"/>
    <s:Button label="3" styleName="sampleStyle"/>

...while I could simply use a type selector and keep my MXML code a lot cleaner and readable.

    <fx:Style>
        @namespace s "library://ns.adobe.com/flex/spark";
        s|Button {   color: red;   }        
    </fx:Style>

    <s:Button label="1"/>
    <s:Button label="2"/>
    <s:Button label="3"/>

I didn't found any information on this issue (apart from Adobe documentation which basically just says "that's not possible"), but I'd really like to know the reason behind this.

Is there something I don't get, or are these selectors actually totally useless?


I had this exact same problem! I needed to override the default text color in TextInputs. You can edit the master css file:

my|Component s|Button {
    color: red;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜