开发者

Line-height in actionscript stylesheets

开发者 https://www.devze.com 2023-02-19 05:11 出处:网络
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 thi

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:

  1. set textField.autoSize = TextFieldAutoSize.LEFT; If you then specify width as well, the TextField will resize only in height.

  2. set textField.y = (textField.parent.height - textField.height) * .5;

The latter will place the TextField at the vertical center of its parent DisplayObject.

0

精彩评论

暂无评论...
验证码 换一张
取 消