nadir.shpz
nadir.shpz

Reputation: 124

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,e.g. seperator line is removed or height property resized for each item area.

Or, How to reference default skin class to custom one?

Upvotes: 0

Views: 404

Answers (1)

Sunil D.
Sunil D.

Reputation: 18193

The default skin classes are part of the 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. 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.

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:

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:

<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.

Upvotes: 3

Related Questions