Line-height in actionscript stylesheets
I'm having problems with figuring out the ability to use css stylesheets in actionscript.
I'm trying to verticaly center text inside a textfield. I tried to use line-height but it doesn't do a thing. Does anyone know a solution to this?
Here's my code:
var style:StyleSheet = new StyleSheet();
style.parseCSS("a{color:#" + color + "; fontSize:" + fontSize + "; font-family: " + font + "; line-height: " + stageheight + "; text-align: center;}");
this is the link where i test my flash video:
http://www.stevevo.sin.khk.be/2SFlashGenerator/flashTest.php
You'll notice that other property's like color, fontsize and font 开发者_Go百科are adjustable so the stylesheet itself works fine only line-height doesnt work.
There is no support for vertical padding, margins and alignment in Flash CSS, so you will have to center the TextField instead of the text:
set
textField.autoSize = TextFieldAutoSize.LEFT;
If you then specifywidth
as well, the TextField will resize only in height.set
textField.y = (textField.parent.height - textField.height) * .5;
The latter will place the TextField at the vertical center of its parent DisplayObject.
精彩评论