views:

57

answers:

1

Hi,

I have a few styles that I want to apply to a slider.

I'm aware of the MXML method of definig a mx:Style tag

<mx:Style>

        HSlider{

        }

        .SliderHighlightTrackSkin{

        }

        .SliderTrackSkin{

        }

        .SliderThumbSkin{

        }



    </mx:Style>

Instead of doing it this way I want to define all the styles in a style sheet. I then want to define my slider in a .as file (not an mxml file) and apply the stylesheet to it.

How I can I do this?

Something like the following is what I'm after

levelSlider= new VSlider()
            levelSlider.minimum=0;
            levelSlider.maximum=1;
            levelSlider.value=1;
            levelSlider.y=150
            levelSlider.styleName="sliderStyle.css"
            this.addChild(levelSlider)
A: 

You can include the style sheet into your Flex application from the mxml file of Application class using <mx:Style source="style.css"/> You can add as many css files as needed.

Now if you have a .customCSSClass{} in the css file, you can apply that to your vSlider using vSlider.styleName = "customCSSClass". Global selectors like HSlider{} will apply automatically.

Amarghosh
cool. I didnt realize that defining styles in the main app mxml would filter to the rest of the app.Thanks
dubbeat