1 Reply Latest reply on Jul 21, 2008 11:11 PM by Noelbaland

    External Text and setTextFormat

    Z-247
      Hi everyone,

      I have what is hopefully a quick question about getting TextFormat options applied to dynamically loaded external text. I can get the formatting to work when I trigger setTextFormat off of a button's on(release) command, but when using the just _root.mytext.setTextFormat(myformat); nothing happens. It doesn't seem to make a difference if the setTextFormat is called before or after the external text is loaded. Oh, and setNewTextFormat doesn't work either.

      I'm guessing there's a problem with the external next not being loaded at the time the formatting is being applied, but I'm really just shooting in the dark. Anyway, here's the code (all in the main timeline):

      // Create a TextFormat object.
      var txt_fmt:TextFormat = new TextFormat();
      // Specify paragraph and character formatting.
      txt_fmt.bold = true;
      txt_fmt.italic = true;
      txt_fmt.size = 10;
      txt_fmt.kerning = true;
      txt_fmt.letterSpacing = 1;
      _root.StageNotesShell.StageNotes.setTextFormat(txt_fmt);

      and then to load the text:

      var textVars:LoadVars = new LoadVars();
      textVars.load("stage6_files/stage_text.txt");
      textVars.onLoad = function(){
      StageNotesShell.StageNotes.htmlText=this.Notes
      }

      Thanks for your help,

      Z-247
        • 1. Re: External Text and setTextFormat
          Noelbaland
          Hello

          Set the textFormat object inside the onLoad function for your LoadVars object.

          So cut this line

          _root.StageNotesShell.StageNotes.setTextFormat(txt_fmt);

          and paste it in here

          textVars.onLoad = function(){
          StageNotesShell.StageNotes.htmlText=this.Notes
          _root.StageNotesShell.StageNotes.setTextFormat(txt_fmt);
          }

          You wait for all the text to load and then make changes to the textfield

          Hope that helps