gre*_*reg 5 css apache-flex skinning flex4
是否有任何方法可以为组件创建自定义css值并使其可用于组件正在使用的外观类?例如,如果我在css文件中定义它:
s|Panel{
skinClass: ClassReference("PanelSkin");
myCustomValue: #CCCCFF;
}
Run Code Online (Sandbox Code Playgroud)
有没有办法myCustomValue提供PanelSkin?
即使没有组件类的[Style]元数据,您似乎可以设置CSS属性,它们也可以在皮肤中使用.作为测试,我创建了一个自定义皮肤并将其附加到SkinnableComponent,然后通过CSS设置属性"特殊颜色".在皮肤中,我绑定到"{getStyle('specialColor')",并检索我设置的属性值.
通过省略元数据可能会牺牲的是CSS上的自动完成功能.
我的测试代码:
SkinTest.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/halo";
s|SkinnableComponent {
skin-class: ClassReference("skins.CustomSkin");
special-color: blue;
}
</fx:Style>
<s:SkinnableComponent width="300" height="300"/>
</s:Application>
Run Code Online (Sandbox Code Playgroud)
CustomSkin.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo" width="400" height="300">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Rect left="0" top="0" right="0" bottom="0">
<s:fill>
<s:SolidColor color="{getStyle('specialColor')}"/>
</s:fill>
</s:Rect>
</s:SparkSkin>
Run Code Online (Sandbox Code Playgroud)