# textHeight property wrong?

**URL:** <https://forum.kirupa.com/t/textheight-property-wrong/295754>\
**Category:** Uncategorized\
**Created:** [September 3, 2009, 8:02pm UTC](https://forum.kirupa.com/t/textheight-property-wrong/295754 "2009-09-03T20:02:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdoe](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@jdoe](https://forum.kirupa.com/u/jdoe)\
**Post date:** [September 3, 2009, 8:02pm UTC](https://forum.kirupa.com/t/textheight-property-wrong/295754/1 "2009-09-03T20:02:40Z")

</div>

Hi:

I need to distribute some images vertically parallel to a dynamic text field wich content is loaded from an XML file. The first image top-aligned, the last one bottom-aligned and equal gap between them. Easy, no? That’s what i thought but I’m banging my head as I can’t get it and my only guess is the textHeight property has a wrong value

I calculate the gap between images with:

imgGap = (txtHeight - imgsHeight) / (nImgs - 1);

## the problem is that the first 8 images reach the textfield bottom: 1046 px (the sum of the first 8 images) 1281 px (7 gaps x 183)

2327 px versus the textHeight property being 4646 px (numLines x getLineMetrics(0).height = 4665)

Any idea what’s wrong? Thanks in advance

# Traces height: 310 textHeight: 4646 numLines: 311 getLineMetrics(0).height: 15 maxScrollV: 291

# imgsHeight: 2080 nImgs: 15 imgGap: 183

setTextFormat();  
[INDENT]…  
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);  
xmlLoader.load(url);[/INDENT]  
}

private function LoadXML(par:Event):void {  
[INDENT]var xmlData:XML = new XML(par.target.data);  
buildInterface(xmlData);[/INDENT]  
}

private function buildInterface(xmlData:XML):void {  
[INDENT]…  
setTexto(xmlData.texto);  
…[/INDENT]  
}

private function setTexto(texto:String):void {  
[INDENT]item\_txt = new TextField();  
item\_txt.embedFonts = true;  
item\_txt.defaultTextFormat = textDef\_fmt;  
item\_txt.x = txtLeft;  
item\_txt.y = txtTop;  
item\_txt.width = txtWidth;  
item\_txt.height = txtHeight; // 310 px  
item\_txt.multiline = true;  
item\_txt.wordWrap = true;  
item\_txt.antiAliasType = AntiAliasType.ADVANCED;  
item\_txt.gridFitType = GridFitType.PIXEL;  
item\_txt.sharpness = 0;  
item\_txt.htmlText = texto;  
item\_txt.selectable = false;  
item\_txt.mouseEnabled = false;  
addChild(item\_txt);  
// 2/9/09: equal gap between images  
trace("height: ", item\_txt.height);  
trace("textHeight: ", item\_txt.textHeight);  
trace("numLines: ", item\_txt.numLines);  
trace("getLineMetrics(0).height: ", item\_txt.getLineMetrics(0).height);  
trace("maxScrollV: ", item\_txt.maxScrollV);  
if (sp != null) sp.txtHeight = item\_txt.textHeight; // set the text height for the class wich loads and show images  
if (item\_txt.maxScrollV \> 1) setScroll();[/INDENT]  
}

private function setTextFormat() {  
[INDENT]txtFont = new menuItems();  
textDef\_fmt = new TextFormat();  
textDef\_fmt.font = txtFont.fontName;  
textDef\_fmt.color = 0x58595B;  
textDef\_fmt.size = 11;  
textDef\_fmt.letterSpacing = 1;  
textDef\_fmt.leading = 4;  
textDef\_fmt.kerning = true;  
textDef\_fmt.align = “left”;  
textDef\_fmt.leftMargin = 0;  
textDef\_fmt.rightMargin = 25;[/INDENT]  
}
