1
votes

I am trying to determine the height of a Spark label that becomes multiline at runtime (due to width property being set), to account for text overflow.

(For a spark label named Title) I have tried:

Title.measureText(Title.text).height - this seems to return only the height of one line. (Due to differing screen-sizes and font rendering, I don't know in advance how many lines the text would overflow to...)

Title.height - this seems to return the height of the label size (before being re-adjusted at runtime for multiline text flow)

Both properties above return an unchanging value even when different text lengths/multiple lines long are filled in .text

Is there really no way to determine the exact height of an overflow Spark label?


I am admittedly not that familiar with the Flex API but after scouring the manual for quite some time, I am still unable to place this title label with the proper spacing. Any help would be appreciated.

2
you might already know this, but conventionally, AS3 class names are CamelCase and instance names are headlessCamelCase.Pranav Hosangadi

2 Answers

1
votes

I think resize event of Spark label will be usefull.
just try this example application This may Help You

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" >

<fx:Script>
    <![CDATA[
        public var Height:String="";
        public function Resize():void
        {
            Height=lblLabel.height.toString();
            txtText.text="Label Height:  "+Height;
        }
        public function AddText():void
        {
            lblLabel.text += lblLabel.text;
        }


    ]]>
</fx:Script>
    <mx:Text id="txtText"  x="46" y="44" width="200"/>
    <s:Label  id="lblLabel" text="Label Text " x="46" y="99" width="200"  resize="Resize()"/>
    <s:Button id="btnClick" label="AddText" click="AddText()" x="199" y="43"/>
</s:Application>
0
votes

If I understood your question correctly, you can listen to mx.events.FlexEvent.UPDATE_COMPLETE