views:

6015

answers:

3

Hello,

in AS3, I'm making this dynamic textfield that is populated from an XML file based on where the user clicks.

The dynamic textfield has a custom scrollbar to it. My problem is that if the text inserted into the textfield is less than the previously displayed text, you can still scroll the dynamic textfield as far as the previous one.

Is there a way to reset the textfield autoSize?

Many thanks,

A: 

I think this link will tell you exactly what to do.

Are you using any of the standard flex controls? Or, is this flash?

You can set the width of the field to the string length + some space (by binding the width to the string's length/event handling etc). This may be of interest. Of course,

dirkgently
arrrg.. code does not display correctly. Anyway, is Flash, and see... the textfield never disappear the stage it just updates the text. Does it help?
Ole Media
Then it is not a `dynamic textfield`. Only, the text is. I'll update my answer with a link.
dirkgently
hmm.. Did you update the link? I don't see the latest link.
Ole Media
there are 2 links (1st and last line respectively). Check the one on the first line.
dirkgently
+1  A: 

If you are talking about Flash ( I have very little experience in Flex ) then the textField.autosize property would probably get you in the right direction.

Charlie boy
A: 

Try this, wrap the xml elements text in

<text><![CDATA[<span class="someClass">Some Text Here</span>]]></text>

If the prior wasn't wrapped in CDATA, flash would have taken the and attempted to drop it down a line and indent it as you would with XML heirarchy; CDATA tells flash to ignore those characters and literally treat them as a string. The result of not using this process is that there are many odd spacings in your textfield.

Also be sure that your TextField is set to Multiline and wordwrap, as well as autoSize such as TextFieldAutoSize.LEFT;

Brian Hodge
hodgedev.com blog.hodgedev.com

Brian Hodge