use a style sheet in flex using no MXML
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 VSlid开发者_运维知识库er()
levelSlider.minimum=0;
levelSlider.maximum=1;
levelSlider.value=1;
levelSlider.y=150
levelSlider.styleName="sliderStyle.css"
this.addChild(levelSlider)
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.
精彩评论