flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: dynamic text filed
Date Tue, 11 Mar 2014 23:46:37 GMT
I don't know if that will be 100% accurate since I think it uses TextField
to measure and TextLine can in Spark can be slightly different.

-Alex

On 3/11/14 3:50 PM, "Justin Mclean" <justin@classsoftware.com> wrote:

>Hi,
>
>Something like this help?
>
><?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[
>			import spark.events.TextOperationEvent;
>			
>			protected function changeWidth(event:TextOperationEvent):void
>			{
>				var textMetrics:TextLineMetrics = ti.measureText(ti.text);
>				var textWidth:int = textMetrics.width;
>				
>				ti.width = Math.max(30, textWidth+10);
>			}
>			
>		]]>
>	</fx:Script>
>	
>	<s:TextInput id="ti" width="30" change="changeWidth(event)" />
>	
></s:Application>
>
>
>Justin


Mime
View raw message