Actionscript 2, Actionscript 2.0, Flash, Flash _

Dynamic TextField Line Counter – Actionscript Example

This simple tutorial helps you determine number of lines in dynamic textfield. It is not a big problem with single line diplayed textfield but with multiple lines displayed it needs a little trick and that’s reseting height of a box to single line height. It is not affecting display of textfield but it resolves bug of returning number of lines in TextField with maxscroll property.
Anyway this example is brought to you by WhiteWeedow (http://mirko.highbox.net/) and here are the files

SWF
FLA

EDIT: links are repaired, sorry for waiting !

Advertisements
Standard

12 thoughts on “Dynamic TextField Line Counter – Actionscript Example

  1. SlowX says:

    So simple, yet so needed.
    Thanks!

    Director’s Lingo had all sorts of ways to select text. Flash seems to make this a bit tougher…

  2. This is simple, and it works so far:

    // number of lines showing in myText:
    numLines = (this[“item” + i].mensaje.bottomScroll – this[“item” + i].mensaje.scroll)+1;
    // number of lines you can scroll down:
    myMaxScroll = this[“item” + i].mensaje.maxscroll;
    // total number of lines:
    myTotalLines = numLines + (myMaxScroll-1);

  3. Pavlis 613 says:

    WhiteWeedow, thanks for the code. I needed it for a AS3 app, but your code was great to get me started.

    I thought I would share the AS3 code that I came up with:

    embedSize = tip.height;
    tip.multiline = true;
    tip.wordWrap = true;

    btn_addText.addEventListener(MouseEvent.CLICK,f_addText);
    function f_addText(event:MouseEvent)
    {
    tip.autoSize = TextFieldAutoSize.LEFT;
    tip.height = embedSize; // here is the trick, try removing this line to see how bugs appear
    tip.text = holder.text;

    var numLines:int = ((tip.maxScrollV – tip.maxScrollV)+1);
    // number of lines you can scroll down:
    myMaxScroll = tip.maxScrollV;

    // total number of lines:
    myTotalLines = numLines + (myMaxScroll-1);

    // number of lines showing in holder:
    output_.text = “DYNAMIC TEXTFIELD HAS “+ myTotalLines +” LINES”;
    };

  4. I know this web site gives quality dependent posts and additional data, is there any other website which gives these kinds of
    stuff in quality?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s