I found my solution (should anyone be trying a similar thing).

I needed to add this to my code:

if(unscaledWidth <= this.measuredWidth) this.textField.scrollH = 0;

I overrode the updateDisplayList with the following ->
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
   super.updateDisplayList(unscaledWidth, unscaledHeight);
   if(unscaledWidth <= this.measuredWidth) this.textField.scrollH = 0;
}

Thanks to Josh Tynjala for his Auto-Resizing TextInput component on the exchange. that is where I found my missing piece of code.

- Kevin


On Nov 6, 2007, at 4:29 PM, Kevin wrote:

I am trying to extend a TextInput component to resize itself as the user types. I have overridden the "measure" function to calculate the size correctly, and then I created a "handleChange" function which calls "invalidateSize()" and recalculates the size as the user types.

Here is the problem: horizontalScrollPosition

When the user types the text is automatically scolled to the left a little bit which makes the first character unreadable. I am assuming this is because the scroll position is getting calculated before the new width is set and thus it is seeing that the bounding box is too small. However, I can't seem to find out where this calculation occurs and how to force it to calculate using the updated width.

Any ideas? Has anyone creating something like this that I can look at?

Thanks, Kevin



Reply via email to