在HSlider控件中使用嵌入字体。
HSlider控件的fontFamily 和labelStyleName样式学习。
示例:
也可以通过CSS设置:
也可以通过AS的方法来设置:
示例:
代码:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/06/04/using-an-embedded-font-with-the-slider-controls-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Style>
@font-face {
src: local("Base 02");
fontFamily: EmbeddedBase02;
}
.sliderLabelStyleName {
fontFamily: EmbeddedBase02;
}
</mx:Style>
<mx:HSlider id="slider"
minimum="0"
maximum="20"
value="0"
labels="[0,5,10,15,20]"
snapInterval="1"
tickInterval="1"
liveDragging="true"
labelStyleName="sliderLabelStyleName"
width="200" />
</mx:Application>
<!-- http://blog.flexexamples.com/2008/06/04/using-an-embedded-font-with-the-slider-controls-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Style>
@font-face {
src: local("Base 02");
fontFamily: EmbeddedBase02;
}
.sliderLabelStyleName {
fontFamily: EmbeddedBase02;
}
</mx:Style>
<mx:HSlider id="slider"
minimum="0"
maximum="20"
value="0"
labels="[0,5,10,15,20]"
snapInterval="1"
tickInterval="1"
liveDragging="true"
labelStyleName="sliderLabelStyleName"
width="200" />
</mx:Application>
也可以通过CSS设置:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/06/04/using-an-embedded-font-with-the-slider-controls-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Style>
@font-face {
src: local("Base 02");
fontFamily: EmbeddedBase02;
}
Slider {
labelStyleName: sliderLabelStyleName;
}
.sliderLabelStyleName {
fontFamily: EmbeddedBase02;
}
</mx:Style>
<mx:HSlider id="slider"
minimum="0"
maximum="20"
value="0"
labels="[0,5,10,15,20]"
snapInterval="1"
tickInterval="1"
liveDragging="true"
width="200" />
</mx:Application>
<!-- http://blog.flexexamples.com/2008/06/04/using-an-embedded-font-with-the-slider-controls-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Style>
@font-face {
src: local("Base 02");
fontFamily: EmbeddedBase02;
}
Slider {
labelStyleName: sliderLabelStyleName;
}
.sliderLabelStyleName {
fontFamily: EmbeddedBase02;
}
</mx:Style>
<mx:HSlider id="slider"
minimum="0"
maximum="20"
value="0"
labels="[0,5,10,15,20]"
snapInterval="1"
tickInterval="1"
liveDragging="true"
width="200" />
</mx:Application>
也可以通过AS的方法来设置:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/06/04/using-an-embedded-font-with-the-slider-controls-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
initialize="init();">
<mx:Script>
<![CDATA[
import mx.controls.HSlider;
[Embed(systemFont="Base 02",
fontName="EmbeddedBase02",
advancedAntiAliasing="true",
mimeType="application/x-font")]
private var EmbeddedBase02:Class;
private var slider:HSlider;
private function init():void {
var labelStyleName:CSSStyleDeclaration = new CSSStyleDeclaration();
labelStyleName.setStyle("fontFamily", "EmbeddedBase02");
StyleManager.setStyleDeclaration(".sliderLabelStyleName", labelStyleName, true);
slider = new HSlider();
slider.minimum = 0;
slider.maximum = 20;
slider.value = 0;
slider.labels = [0, 5, 10, 15, 20];
slider.snapInterval = 1;
slider.tickInterval = 1;
slider.setStyle("labelStyleName", "sliderLabelStyleName");
slider.width = 200;
addChild(slider);
}
]]>
</mx:Script>
</mx:Application>
<!-- http://blog.flexexamples.com/2008/06/04/using-an-embedded-font-with-the-slider-controls-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
initialize="init();">
<mx:Script>
<![CDATA[
import mx.controls.HSlider;
[Embed(systemFont="Base 02",
fontName="EmbeddedBase02",
advancedAntiAliasing="true",
mimeType="application/x-font")]
private var EmbeddedBase02:Class;
private var slider:HSlider;
private function init():void {
var labelStyleName:CSSStyleDeclaration = new CSSStyleDeclaration();
labelStyleName.setStyle("fontFamily", "EmbeddedBase02");
StyleManager.setStyleDeclaration(".sliderLabelStyleName", labelStyleName, true);
slider = new HSlider();
slider.minimum = 0;
slider.maximum = 20;
slider.value = 0;
slider.labels = [0, 5, 10, 15, 20];
slider.snapInterval = 1;
slider.tickInterval = 1;
slider.setStyle("labelStyleName", "sliderLabelStyleName");
slider.width = 200;
addChild(slider);
}
]]>
</mx:Script>
</mx:Application>