简体   繁体   English

如何修改默认的火花皮肤类?

[英]How to modify default spark skin classes?

I just want to set one property from default class.But I could't do this successfully yet. 我只想从默认类中设置一个属性。但是我还不能成功做到这一点。

Why I asked this question? 为什么我问这个问题? I wanted to set Spark List view, but when I create a new Item Renderer, some of default properties changes,eg seperator line is removed or height property resized for each item area. 我想设置“ Spark List”视图,但是当我创建一个新的Item Renderer时,一些默认属性会发生变化,例如,删除分隔线或为每个项目区域调整height属性的大小。

Or, How to reference default skin class to custom one? 或者,如何引用默认外观类以自定义一个?

The default skin classes are part of the Flex SDK. 默认外观类是Flex SDK的一部分。 So you can't really modify them unless you edit the classes in your SDK and do all necessary steps to recompile it. 因此,除非您在SDK中编辑类并执行所有必要的步骤以重新编译它,否则您实际上无法对其进行修改。 Obviously, this is not a good approach. 显然,这不是一个好方法。

Instead you should extend the skin classes that you wish to modify. 相反,您应该扩展要修改的外观类。 After you do that, you can use CSS to make your new skin class the default skin for a given component. 完成此操作后,可以使用CSS将新的外观类设置为给定组件的默认外观。

Example skin class: 皮肤类别示例:

package com.mycompany.skins
{
    import spark.skins.spark.ButtonSkin;

    public class MyButtonSkin extends ButtonSkin
    {
        // add new properties or set new values on existing properties
        public myCustomProperty:Boolean = true;
    }
}

CSS: CSS:

s|Button { 
    skinClass: ClassReference("com.mycompany.skins.MyButtonSkin"); 
}

The other approach would be to extend the skin class as above. 另一种方法是如上所述扩展皮肤类别。 However, instead of using CSS to make it the default skin, you would specify the skin class on each component: 但是,不要使用CSS使其成为默认外观,而应在每个组件上指定外观类:

<s:Button id="myButton" skinClass="com.myCompany.skins.MyButtonSkin" />

This is obviously more tedious than using CSS, but will let you selectively apply the skin where you want it. 这显然比使用CSS更为繁琐,但是可以让您有选择地将皮肤应用于所需的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM