A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: issues with single carriage returns

  1. #1
    Senior Member
    Join Date
    Mar 2004
    Location
    Upper Marlboro, MD
    Posts
    146

    issues with single carriage returns

    I'm having the hardest time trying to get my dynamic text box to display single line feeds instead of doubles. I can't find a solution.

    I have a text file named "mFile.txt" and the following content:

    2nd Saturday at Twelve Lounge
    1123 H Street/ NE Washington DC 20003
    Battle of the hottest djays


    In my movie, I have a movieclip on the stage called: "mc3"

    Inside that movie clip is a dynamic text box with a instance name of "txt1"
    In the code of the movie clip, I have the following AS:

    Code:
    var R;
      //
      res=new LoadVars();
      res.load("mfile.txt");
    
      res.onData=function(info){
        if (info==undefined){
          R="Loading failed";
        }else{
           R=info;
        }
        txt1.text=R;
      }
    When I play my movie the content from the text file is displayed like this:

    2nd Saturday at Twelve Lounge

    1123 H Street/ NE Washington DC 20003

    Battle of the hottest djays


    What do I need to do to get it to display with the single line?

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    It's a double-linebreak, simply switch it to a single-linebreak:

    Actionscript Code:
    var R;
      //
      res=new LoadVars();
      res.load("mfile.txt");

      res.onData=function(info){
        if (info==undefined){
          R="Loading failed";
        }else{
           R=info.split("\r\n").join("\n");
        }
        txt1.text=R;
      }
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Senior Member
    Join Date
    Mar 2004
    Location
    Upper Marlboro, MD
    Posts
    146
    Hi,
    Thank you but I'm receiving a syntax error on the following line:

    Code:
     R=info.split("\r\n").join("\n");
    it telling me that its expecting a variable for the property target.

    Should I be including the variable "R" some kind of way. I don't understand the error.

    FYI, I'm using actionscript 1.0

  4. #4
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Actionscript 1.0 :O??

    Now that's old, but I changed my settings to Actionscript 1.0 and Flash Player 6, and tried the code above, and it worked perfectly
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  5. #5
    Senior Member
    Join Date
    Mar 2004
    Location
    Upper Marlboro, MD
    Posts
    146
    Ok. I will try it again. Maybe my text box has to be set to HTML even though it doesn't contain any HTML. What do you think?

  6. #6
    Senior Member
    Join Date
    Mar 2004
    Location
    Upper Marlboro, MD
    Posts
    146
    nope. still didn't work. It doesn't like this line:

    R=info.split("\r\n").join("\n");

    its expecting a variable for the property target. I don't even know what that means to fix it.

    what is this line suppose to do: R=info.split() ..

  7. #7
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    R=info.split("\r\n").join("\n");

    \r\n = double-linebreak
    \n = single-linebreak

    it's basically removing all the double-linebreaks from the fetched data from the text file, making all the text in-between being saved into one single array, and then it's joining that array by joining all array indexes (text parts) with single-linebreak. In other words, it's replacing all the double-linebreaks with single-linebreaks

    I checked the documentation online, and it says that Actionscript 1.0 supports split() and join(), so I don't know why it's not working. Mind posting your FLA file?
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  8. #8
    Senior Member
    Join Date
    Mar 2004
    Location
    Upper Marlboro, MD
    Posts
    146
    Oh .. maybe thats the problem .. I'm using KoolMoves software. not Flash. I wonder ...

    guess I need to post this on the koolmoves forum.

  9. #9
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    oh, that's probably the issue
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

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