A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: load variable adds extra return... ???

  1. #1
    Senior Member Knoj's Avatar
    Join Date
    Sep 2000
    Location
    Ames IA
    Posts
    361
    Hi,

    I am loading a variable into flash that normally has half as many returns (\n) I don't know how this happens, but when it goes into flash, it adds extra returns... Does any one know how to remove all of either the \r or the \n chars?

    I would need this to be an action script answer... I am stumped... I have tried and tried, but I may just be doing the wrong thing...

    Thank you for any help you can give me!

  2. #2
    Senior Member
    Join Date
    Jun 2001
    Posts
    2,943
    If you know how many extra characters there are, use:
    Code:
    myStr=myStr.slice(0,myStr.length-2);
    This example returns the string with two characters cut off.

  3. #3
    Senior Member Knoj's Avatar
    Join Date
    Sep 2000
    Location
    Ames IA
    Posts
    361
    Thank you, but...

    My problem is not with extra characters at the end, my problem is on a multi-line text area. Every return carage becomes 2 return carages. I want to remove either the \rs or the \ns...

    Any one?
    Thanks.

  4. #4
    Senior Member
    Join Date
    Jun 2001
    Posts
    2,943
    I'm sorry if I'm misunderstanding, but \rs and \ns are single characters which can be removed as such.

    If you had a string:

    myVar="abcdeg\r\n"

    then the code I gave will remove the \r and \n.

    I wasn't aware that Flash added them when it read variables (I'm sure it doesn't, because it doesn't when I use it ).

  5. #5
    Senior Member Knoj's Avatar
    Join Date
    Sep 2000
    Location
    Ames IA
    Posts
    361
    Actually, the additional return chars are when I load from a form variable into a flash variable with JavaScritp. What I want to remove is not as simple as removing \r\n from abcdeg\r\n it's more like removing all of the \r from a string like: abcd\r\nefghij\r\nklmno\r\npqrs...

    Like I said in my second post, I am working on a multi-line text field.

    Thanks again for your help!

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