Has anyone successfully used TextLineMetrics with multiline text 
fields?  All my experiments are showing that it always computes 
assuming a single, not wrapping line of text.  I'm not sure if im 
using it wrong (the most likely scenario), if its a documentation 
error, or a bug.  According to the docs, the TextLineMetrics width 
property should be the width of the text within a text field, 
however, I'm finding if I have a Text control with a width of 300, 
and a few lines of text within it, the width property shows the 
width as if it were on one line of text, and the height is 
indicating the height of a single line of text.  

Here is an example:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
layout="vertical">
    <mx:Style>
        .bigRed{
            font-family:Arial;
            font-size:40;
            color:#330000;
        }
    </mx:Style>
    <mx:HBox>
        <mx:Button label="Measure" click="measureTheText()"/>
        <mx:Button label="Style" click="doStyle()"/>
        <mx:Button label="Clear Style" click="clearTheStyle()"/>
    </mx:HBox>
    <mx:TextInput id="enteredText"/>
    <mx:Text id="output" text="{enteredText.text}" width="300" />
    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;
            private function measureTheText():void{
                var tlm:TextLineMetrics = output.measureText
(enteredText.text);
                var h:int = tlm.height;
                var w:int = tlm.width;
                Alert.show("text is " + w.toString() +"x"+h.toString
());
            }
            private function doStyle():void{
                output.setStyle("styleName","bigRed")
            }
            private function clearTheStyle():void{
                output.clearStyle("styleName");
            }
        ]]>
    </mx:Script>
</mx:Application>






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to