dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Breaking string by visible lines

  1. #1
    Senior Member
    Join Date
    Mar 2000
    Posts
    182
    yo!

    i have a looong string. and when displayed in a txt field it, ofcourse, does not display entirely.

    now, i want to break it into 2 new strings, first one consisisting of only visible part in first txt field, and the second one of the rest.

    is there a way to do that?

  2. #2
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    Hi,

    I presume that you know about word-wrapping and multiline textfields?

    With actionscript, the 'substring' or 'substr' methods of the String object will cut the string into pieces for you:

    Code:
    str = "hello there";
    str1 = str.substring(0,5); // "hello"
    str2 = str.substring(5); // " there"
    To really make this work though, you will have to calculate how many characters will fit into the first text field. You can use the 'flash string width calculator' from http://www.swfx.org for that...

    hope this has helped,

    - n.

  3. #3
    Senior Member
    Join Date
    Mar 2000
    Posts
    182
    Hm, yea i can break it that way by characters, but how do i know number of visible characters?

    It would be cool if i could Substring by LINES not by characters. You get me?

  4. #4
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    Hi,

    well - this is what you have to use the 'flash string width calculator' for.

    Basically, if your text field is 200 pixels wide, you can use the calculator to calculate () how many characters of your string fit into the first line etc. Have a look at the website I linked to, it explains it a little better...

    - n.

  5. #5
    Senior Member
    Join Date
    Mar 2000
    Posts
    182
    Eh, i do not have that Java thing installed. But cool site there, nice JPG->SWF things

    Yo, but i found a way to do it in the meantime. With .scroll variable.

    I do not actualy need to cut the string, i can just move it to a different scroll level.

    Ah well, it is not perfect, but serves my purpose.

    Thanks

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