Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
0

New line return in windows Notepad

Explorer ,
Jan 18, 2016 Jan 18, 2016

I have a text field that is populated and shown in my app.

It displays as it should.

I use the \r\n for the mandatory next line. It works fine in the flash app.

Problem is that when I save out the text field to a .txt file, it is all on a single line.

I have tried to use \u000d \u000a as well as  \x0d \x0a with no affect to the text document.

It is in Flash pro cs6 in an Air app.

TOPICS
ActionScript
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 19, 2016 Jan 19, 2016

What version of AIR are you using? What is your code for saving out the text file?

I made a quick example file testing this and it seems to work fine. I am using Flash CC 2015 and AIR 17.0.0.124 for Desktop and am working on a Mac Pro running Mac OS X 10.10.5 Yosemite. I created a new AIR FLA for desktop, created a dynamic TextField on the stage, gave it an instance name of "textfield_txt", set the text to "this is a bunch of line breaks" with a line break after each word (no spaces). Then I made a new layer and started coding up a File and FileStream objects to save the text from the TextField to an existing ".txt" text file on my desktop named "lineBreaks.txt". When my TextField was NOT set to Multiline for the "Behavior" property under "Paragraph" options in the Properties inspector, it rendered everything together as one long run on word. When I changed it to Multiline, it wrote to the .txt file with the line breaks. Here is my code:

import flash.events.Event;

import flash.events.IOErrorEvent;

import flash.filesystem.File;

import flash.filesystem.FileMode;

import flash.filesystem.FileStream;

import flash.text.TextField;

var textfield_txt:TextField;

var textFile:File = File.desktopDirectory;

textFile = textFile.resolvePath("lineBreaks.txt");

var fs:FileStream = new FileStream();

fs.open(textFile, FileMode.WRITE);// open for writing to the text file

fs.writeUTFBytes(textfield_txt.text);// write the .text String from the TextField into the File

fs.close();// close FileStream and then setup listeners for opening back up and reading new text data

fs.addEventListener(Event.COMPLETE, onFileLoaded);

fs.addEventListener(IOErrorEvent.IO_ERROR, onFileLoadFail);

fs.openAsync(textFile, FileMode.READ);// regular .open() doesn't seem to dispatch Event.COMPLETE for knowing it is ready for reading

function onFileLoaded(e:Event):void {

  trace(fs.readUTFBytes(fs.bytesAvailable));

}

function onFileLoadFail(e:IOErrorEvent):void {

  trace(e.toString());

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 19, 2016 Jan 19, 2016

HI

I am working in Windows 10 pro and using Air 3.4 for desktop. It is the latest version available to me.

For clarification, this is for the base text program in windows. Which is Notepad.

If I open in another program that has more power, such as WordPad or OpenOffice it displays fine.

Also if I save a txt file from any text editing program and then open it in Notepad, it reads fine.

So I would conclude that it is the write engine in flash.

Here is my code that I am using.

    import flash.filesystem.*;     

    import flash.events.Event;

    function onSave(event:Event):void {

    var file:File=File.applicationStorageDirectory;     

    file=file.resolvePath("TEMP directory/"+  title_txt.text +"/"+  title_txt.text +".txt");     

    var fileStream:FileStream = new FileStream();     

      fileStream.open(file, FileMode.WRITE);     

      fileStream.writeUTFBytes(result_txt.text + "");     

      fileStream.addEventListener(Event.CLOSE, fileClosed);     

      fileStream.close();   

    function fileClosed(event:Event):void {         

     trace("closed event fired");     

    }

   }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 19, 2016 Jan 19, 2016

Interesting. I don't see anything wrong with what you have from a functionality standpoint. Is the AIR 3.4 a company limitation or are there other reasons for not using the newest version of AIR?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 19, 2016 Jan 19, 2016

The air version is the latest one that is in the FlashProfesional cs6 that I am using.

I have installed the latest Air runtime and Flash player, but this has not made any difference to the core program.

So I am limited to that version. Perhaps the core program it is not getting any updates as cc is now the main player.

But I don't think that that should make a difference.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 19, 2016 Jan 19, 2016

The AIR runtime is what allows AIR applications to function and the newer the runtime, the more feature available to AIR apps. It is actually really easy to use the latest version of AIR for publishing with CS6. Download the AIR SDK from Download Adobe AIR SDK and extract the archived folder. The extracted folder is the SDK and will likely be named something like "AIR SDK blah blah". Im not sure what the archive format is for Windows, but you might need WinRar or 7-Zip to extract it. After that, I would suggest renaming it to AIR20 for simplicities sake and letting you keep track of it in the future if you decide to update often. Once you have that done, move it into the Adobe Flash CS6 application folder where AIR3.2 and AIR3.4 are located. Once you have done that, switch over to Flash CS6. Under the "Help" menu at the top of the Flash CS6 app window, there is a "Manage Adobe AIR SDK..." option. Select that and you can then see a small popup window listing the versions of AIR you can publish to. Since AIR 3.2 and 3.4 are part of the app install, you can't remove those but you can click the "+" to browse for the AIR20 folder and add it to the list. Once that is done, you can switch the AIR version in the Properties inspector to the newest version of AIR.

If it makes you feel any better, people using Flash CC have to do this same thing if they want to use the newest version of AIR. The AIR SDK does get updated with CC but only when there is a major software update to it, like when it went from Flash CC to Flash CC 2015 and then again with Flash CC 2015.1 updates.

Whether or not it makes a difference, you never know. Adobe could have change how some things are handled on the backend and it might have fixed the issue you are having.

Could you provide an example string to work with that I might further look into it for you if using the newest version of AIR doesn't correct the problem?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 06, 2016 Feb 06, 2016
LATEST

Has anyone found a fix for this yet?

Is it the same on all Flash platforms?

Why is it not saving the "Line Feed" into the document?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 20, 2016 Jan 20, 2016

Since you marked your posted code as the correct answer, could you explain what the fix was for the benefit of others that might have this issue in future projects? Thank you.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 20, 2016 Jan 20, 2016

Sorry. I never marked anything as fixed ( not as yet ) so no idea why it was marked.

I did install the update, thanks for that šŸ™‚

Unfortunately the above issue is still not fixed..

OK then. I did an experiment.

I made a short text file in my app, then made a copy and opened the copy with WordPad.

I then saved it (without any editing, just opened and hit save).

Both files were opened up in Hex Editor.

On the relevant hex, "0D0A09" is the copy-resaved-file, and "0D09" is the original no-edit-file.

According to Wiki, you find this :  CR+LF: CR (U+000D) followed by LF (U+000A)

LF is Line Feed

CR is Carriage Return

So line feed is not being saved into the text file in flash.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines