开发者

Is there a way to declare a skin inline?

Is there a way to declare a skin开发者_如何学JAVA inline in a Flex 4 MXML Component? If not inline in the component then in the declarations or library tag? Thx


Yes you can in the declarations tag:

<s:Application>

<fx:Declarations>
    <fx:Component className="testSkin">
        <s:Skin>
            <s:Rect width="100%" height="100%">
                <s:fill>
                     <s:SolidColor/>
                </s:fill>
            </s:Rect>
            <s:Group id="contentGroup"/>
        </s:Skin>
    </fx:Component>  
</fx:Declarations>

<s:SkinnableContainer skinClass="{Class(testSkin)}"/>

</s:Application>

The above code is merely guidance, don't expect it to compile.

In my tests, there is no performance penalty to using inline skins.


Use the skinClass style.

In MXML, like this:

<s:List skinClass="com.myCustomSkins.MyCustomListSkin" />

In ActionScript, do something like this:

 myListClass.setStyle('skinClass',com.myCustomSkins.MyCustomListSkin);

In CSS, do something like this:

myListClass{
 skinClass : ClassReference(com.myCustomSkins.MyCustomListSkin);
}

I'm not sure what a library tag is that you refer to in your question. This code is from memory, so my syntax may be a bit off.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜