3 Replies Latest reply on Aug 11, 2010 8:04 AM by CowAttack

    Retaining Bold and Italics in .txt


      I think what I'm about to ask is impossible, but I wanted to run it by the experts first to be sure.


      I  have a .doc file. I want to load the text from that file into Flash. So  I convert it into a .txt using a website like this one: http://apps.phplivedocx.org/convert/doc-to-txt.  I add in the little code at the beginning (myTextField=) and then Flash  loads it fine. The only problem is any marked up text (italics, bold,  underline) is lost. Is there any way to prevent this from happening? Or  for Flash to load text from something other than a .txt? Or to manually  reinsert html tags to the .txt and get Flash to understand them? Or  something else I'm not considering?


      My text field correctly displays the text in the "PrimaryText.txt" file.  The first line of the text shows like this: <b>Testing this  text</b> instead of just showing up bold. And the "Render text as  HTML" is checked. Thanks in advance.

        • 1. Re: Retaining Bold and Italics in .txt
          Ned Murphy Adobe Community Professional & MVP

          doc files are rich text files that can have all kinds of text formatting applied in them.  txt files are simple ascii text files that only contain text and do not have any formatting for the text.


          To get your bold text to appear when you use html tags and set the html property of the TextField to true (or choose the render as html option in the properties panel), you need to assign the text to the textfield using the htmlText property instead of the text property...


          txt.text = "<b>Bold</b> text"; // displays <b>Bold</b> text


          txt.htmlText = "<b>Bold</b> text";  // displays Bold text


          (ps - please don't crosspost:  it's a courtesy that saves people from unnecessarily posting responses, which I probably just did)

          • 2. Re: Retaining Bold and Italics in .txt
            CowAttack Level 1

            Sweet. Thanks. It was just that one small line. Sorry about the cross post. I don't usually do that but when I posted something in the main Flash forum the person responding said he didn't know AS2, so I moved the post over here.

            • 3. Re: Retaining Bold and Italics in .txt
              Ned Murphy Adobe Community Professional & MVP

              You're welcome