View Full Version : Make "lineheight" attribute read/write
Squids
09-15-2009, 01:51 PM
It looks like the attribute "lineheight" for multine text views in read only...I would be extremely helpful if it was given write access as well so we could change it! How difficult would this be to do?
LaSlow
07-13-2010, 03:34 AM
This feature would be great.
LaSlow
07-27-2010, 09:22 AM
Here is a solution for the lineheight problem:
<canvas name="lineHeight" width="100%" height="100%">
<lineHeightText fontsize="11" fgcolor="#000000" bgcolor="#abcdef"
name="textarea1" width="100" selectable="true">
[start]Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.[end]
</lineHeightText>
<lineHeightText fontsize="11" fgcolor="#000000" x="120" bgcolor="#abcdef"
name="textarea2" width="100" selectable="true">
<handler name="oninit">
<![CDATA[
this.setLineHeight(20);
]]>
</handler>
[start]Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.[end]
</lineHeightText>
<class name="lineHeightText" extends="text" multiline="true">
<switch>
<unless property="$as3">
<method name="setLineHeight" args="newLineHeight:Number =0">
<![CDATA[
Debug.error("setLineHeight is not supported");
]]>
</method>
</unless>
<otherwise>
<passthrough>
import flash.text.*;
</passthrough>
<method name="setLineHeight" args="newLineHeight:Number =0">
<![CDATA[
Debug.write("new line-height should be: ", newLineHeight);
// get an reference of this text
var test = this.getMCRef();
Debug.write("text lines: ", test.textfield.numLines);
Debug.write("text line-height: ", test.lineheight);
Debug.write("textfield height: ", test.lineheight*test.textfield.numLines);
// set new line-height
var format:TextFormat = new TextFormat();
format.leading = newLineHeight-test.lineheight;
Debug.write("current line-height: ", test.lineheight);
Debug.write("format leading: ", format.leading);
// set line-height in the sprites
test.lineheight = 26;
// make this textfield bigger
this.setAttribute("height", newLineHeight*test.textfield.numLines);
// set the new format
test.textfield.setTextFormat(format);
test.textfield.defaultTextFormat = format;
]]>
</method>
</otherwise>
</switch>
</class>
</canvas>
P.S.:
It would be nice to set the new line-height with the lineheight-setter.
But i have not an idea how can i do that :(
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.