A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] Counting characters or lines in text fields..

  1. #1
    Member
    Join Date
    Dec 2006
    Posts
    43

    [RESOLVED] Counting characters or lines in text fields..

    I have an area of my website where there is a persons name, which is pulled from a variable into a dynamic text box.
    Under that name, i have a list of links.

    The problem that i'm having, is that if the persons name is very long, and the dynamic text box wraps the last name to the second line. This is fine, except that the text now is on top of the links that are below it.

    Is there any way that I can count the number of letters in a variable? or any way that flash can detect how many lines there are after the wrapping is done?

    I want to do something like this, given that a name with more than 20 character would cause it to wrap..
    Code:
    if(Number of characters>20){
    linklist._y = (linklist._y +40);
    }
    .. or the same thing for the number of lines after wrapping is done in the text box.
    This would let the links move themselves if the text ends up wrapping.

    Can anybody help me?

  2. #2
    Ximensions.com Sul's Avatar
    Join Date
    Oct 2000
    Location
    UK
    Posts
    423
    You can get the number of characters by using the string.length property.

    So

    code:

    name = "char"
    numchar = name.length //returns 4



    You could set the text field not to wrap, alternatively.

  3. #3
    Member
    Join Date
    Dec 2006
    Posts
    43
    Thanks a bunch!
    Yet another hurdle overcome 8)

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