在AS3中设置ComboBox的字体和宽高

作者: 2010-08-23,09:55 下午 周一

  AS3组件ComboBox的字体类型和字体大小也要用TextFormat,而且要分别对TextField和dropdown设置该TextFormat,设置dropdown的宽和高,ComboBox有个 dropdownWidth属性,却没有对应的dropdownHeight属性,而是要使用dropdown的rowHeight属性!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// combox 是一个ComboBox组件(Component)
// 设置它的宽度和高度
combox.width = 300 ;
combox.height = 48 ;
// 添加几个选项
combox.addItem( { data : 1 ,label: '测试项目一' } ) ;
combox.addItem( { data : 2 ,label: '测试项目二' } ) ;
combox.addItem( { data : 3 ,label: '测试项目三' } ) ;
// 建立一个TextFormat实例
var tft: TextFormat = new TextFormat ( ) ;
// 设置其字体大小为32
tft.size = 32 ;
// 设置其字体为微软雅黑
// 建议大家使用相应的英文名字
tft.font = "宋体" ;
// 设置ComboBox的样式
combox.textField.setStyle('textFormat',tft);
// 设置下拉选项的样式
combox.dropdown.setRendererStyle( "textFormat" , tft) ;
// 设置下拉选项的行高
combox.dropdown.rowHeight = 48 ;
// 设置下拉选项的宽度
// 可以和ComboBox不一样哦
combox.dropdownWidth = 360 ;

相关文章

分类 : FLASH (阅览:) Tags :

评论

还没有评论呢。


留下评论


|:victory:| |:tongue:| |:titter:| |:time:| |:sweat:| |:smile:| |:shy:| |:shocked:| |:sad:| |:mad:| |:lol:| |:kiss:| |:hug:| |:huffy:| |:handshake:| |:cry:| |:call:| |:biggrin:|