A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: how to find number of lines of dynamic text...and how many lines in textfield

  1. #1
    Senior Member k/smaert's Avatar
    Join Date
    Dec 2003
    Posts
    210

    how to find number of lines of dynamic text...and how many lines in textfield [DONE]

    is there any way of finding out how many characters will fit in a dynamic textfield?

    I have a textfield that is dynamically loaded with text. Sometimes the text is long and i need scroll buttons, but when the text is short i would like not display the scroll buttons.

    How can i figure out if text is short enough not to display the scroll buttons?

    oh..to make it even more complicated; the font of the text is not always the same. I use textformatting to display header-like lines in the textfield.
    Last edited by k/smaert; 05-07-2004 at 12:46 PM.

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    Take a look at TextField.scroll and TextField.maxscroll.

  3. #3
    Senior Member k/smaert's Avatar
    Join Date
    Dec 2003
    Posts
    210
    maxscroll shows me only how many lines there is in a textfield not how many lines can fit in the height of the textfield.

    i need to know how many lines will be visible without scrolling and then compare with the text and see how many lines it is filling

    maxscroll is only usuful for the last of these two tasks

  4. #4
    Senior Member
    Join Date
    Apr 2001
    Location
    saskatoon, canada
    Posts
    147
    If you useTextField.autoSize your textfield will increase in size to accomidate more text. You can check to see if _height is greated than you want and add your scroll bars then.

    That worked for me.

  5. #5
    Senior Member k/smaert's Avatar
    Join Date
    Dec 2003
    Posts
    210
    i have a limited space to work on so the textfields have a fixed height....just think it looks stupid to have scrollbars there the times they are not needed...it will only confuse the user

  6. #6
    Senior Member
    Join Date
    Apr 2001
    Location
    saskatoon, canada
    Posts
    147
    The textfield doesn't need to stay big, just test to see if it grew then resize it and add the scroll bars. If it all happens on one frame it is seamless.

  7. #7
    Senior Member
    Join Date
    Apr 2001
    Location
    saskatoon, canada
    Posts
    147
    Also, if you use the scrollPane component that is included with MX and 2004 it will do all of this for you. If the textfield get to big you will get scrollbars.

  8. #8
    Senior Member k/smaert's Avatar
    Join Date
    Dec 2003
    Posts
    210
    ok...i see what you mean, but i just found the easy way now:

    textField.bottomScroll gives me exactly what i need

  9. #9
    Senior Member k/smaert's Avatar
    Join Date
    Dec 2003
    Posts
    210
    actually i was wrong about bottomScroll i thougth i could use it and compare it with maxscroll.

    i wrongly thought that maxscroll would tell me how many lines, but actually what it does is this:

    The maxscroll property tells us how far a field can be scrolled (i.e., how far it must be scrolled until the last line becomes visible). It is always the index of the field's last line minus the number of lines that can be displayed in the viewable region at once, plus one.
    wich i found at http://skaiste.elekta.lt/Books/O'Rei...on/ch18_04.htm

    with this information i figured out that if maxscroll>1 the textfield will need scrolling bars

    thanks for your inputs though..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center