6 Replies Latest reply on Jan 5, 2007 12:06 PM by sl0beck

    Load text with color

    BobAchgill
      How is it possible to load this HTML text from a file and display?

      <p><font color="red">In</font> the beginning,. </p>

      My target platform is an MP3 Player with Flash lite 1.1 ... so I guess I am restricted to Flash 4 code capabilities.

        • 1. Re: Load text with color
          Level 7
          Player 4 has the loadVariables function.

          --
          Dave -
          Head Developer
          www.blurredistinction.com
          Adobe Community Expert
          http://www.adobe.com/communities/experts/


          • 2. Re: Load text with color
            BobAchgill Level 1
            I tried this line...

            loadVariables("data.txt", "data_clip");

            and got this error...


            **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Invalid mouse event specified.
            on (loadVariables("data.txt", "data_clip");

            Total ActionScript Errors: 1 Reported Errors: 1
            • 3. Re: Load text with color
              BobAchgill Level 1
              Are you sure loadvar will display the word "In" in red?

              <p><font color="red">In</font> the beginning,. </p>
              • 4. Re: Load text with color
                Philip C
                1. set the textbox to HTML and then make sure to use .htmlText when puting it in.
                And embed the font

                2. you cant use the word "red" you have to use Hex, so your texfile should look like this:

                <p><font color="#ff0000">In</font> the beginning,. </p>

                3. To avoid all hassle of loading variables from textfiles you can cheat
                easily by pretending your textfile is an XML file, the following code should do the trick.

                var myText:XML = new XML;
                myText.load("textFile.txt");
                myText.onLoad = function(){
                refToYourTextBox.htmlText = myText;
                }

                Hope it helps
                • 5. Re: Load text with color
                  BobAchgill Level 1
                  quote:

                  Originally posted by: Philip C
                  1. set the textbox to HTML and then make sure to use .htmlText when puting it in.
                  And embed the font

                  2. you cant use the word "red" you have to use Hex, so your texfile should look like this:

                  <p><font color="#ff0000">In</font> the beginning,. </p>

                  3. To avoid all hassle of loading variables from textfiles you can cheat
                  easily by pretending your textfile is an XML file, the following code should do the trick.

                  var myText:XML = new XML;
                  myText.load("textFile.txt");
                  myText.onLoad = function(){
                  refToYourTextBox.htmlText = myText;
                  }

                  Hope it helps


                  Some questions about your suggestions... still only seeing raw html when I load the text box.

                  STEP 1:
                  I think I have tried what you suggest in steps 1 but must be misunderstanding. I did not see a place on the properties screen to set the text box to HTML. I did rename my input file to have the extension of vars.htmlTEXT as you suggest. Here is what my button script now looks like...

                  on(release) {
                  loadVariables("vars.htmlText", "_root");
                  }

                  STEP 2:
                  I understand the hex for red.

                  You mention embedding font. Is there a way to embed the whole ttf unicode font that I use? It appears that only certain glyphs provided by adobe are embeddable when I select the embed button. Were you referring to some other way to embed a "whole" font?

                  I am making a free world literacy program that runs on a mp3 player (Flash lite 1.1) Hence the interest in embedding a unicode font.

                  STEP 3:
                  Was not sure what your step 3 was going to help me with. Could you explain a litte more. Kind of new at this.
                  • 6. Re: Load text with color
                    sl0beck
                    Good suggestion. I might add that you use the LoadVars class instead. It's a teeny bit (and I do mean teeny) more involved, but worth it. Using the OO features of AS2 is always the best way top go, for error checking, reuse, refactoring and more.

                    I'm gonna try a couple of things... I'll see what can be done.