[英]Applying Dynamic Styles to Skins in Flex
I have a skin for a scrollbar thumb that I want to be able to style or set properties dynamically. 我有一个滚动条拇指的皮肤,希望能够动态设置样式或设置属性。
<mx:Panel
verticalScrollBarStyleName="verticalScrollBarNoArrows">
</mx:Panel>
style.css style.css
.verticalScrollBarNoArrows
{
upArrowSkin: ClassReference(null);
downArrowSkin: ClassReference(null);
trackSkin: ClassReference(null);
thumbSkin: ClassReference("skins.ScrollBarThumb");
}
ScrollBarThumb.as (snippet) ScrollBarThumb.as(摘要)
public class ScrollBarThumb extends Border
{
[Bindable]
private var cornerRadius:Number = 2;
[Bindable]
private var backgroundColor:uint = 0x222222;
[Bindable]
private var xOffset:int = -3;
I want to be able to set these properties in the skin so the skin can be styled differently for each component that uses it. 我希望能够在皮肤中设置这些属性,以便可以为使用皮肤的每个组件设置不同的皮肤样式。
How do you suggest I do this? 您如何建议我这样做?
You should usually set styles on a skin as styles not as properties: 通常应将皮肤上的样式设置为样式而不是属性:
[Style(name="cornerRadius", type="Number", format="Length", inherit="yes")]
Then in updateDisplayList
you can call getStyle("cornerRadius")
when you draw the skin. 然后,在updateDisplayList
,绘制皮肤时可以调用getStyle("cornerRadius")
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.