3 Replies Latest reply on May 20, 2006 6:15 PM by Miriam_McD

    Format ALL text fields?

    Miriam_McD
      Hi -

      I've searched everywhere and can't find an answer to this, so any help would be appreciated. I have a movie with multiple dynamic text fields. These text fields are drawn into the movie at certain frames (not created using AS). The text is being dynamically created using flashVars.

      I have a global audience and would like to dynamically embed fonts depending on the country. So, into the flashVars section of my HTML, I have:

      font=Embed

      or

      font=noEmbed

      (depending on which country that HTML file will be delivered to)

      So, I'm using _sans as the default font on the textFields (set in the property inspector). I've got code in the first frame of my movie:

      onEnterFrame = function (success) {
      if (_root.font == "Embed") {
      textMC.text.setTextFormat(embedFormat);
      textMC.text.embedFonts = true;
      }
      }

      var embedFormat:TextFormat = new TextFormat();
      embedFormat.font = "LuzSans-Medium";

      This is working great for a single text field. However, I'd like to be able to set this text format for ALL text fields in my movie, rather than having to set each text field separately. Is there a way to do this? By the way, because of my target audience, I need to publish to Flash Player 6, so I don't think I can use CSS.

      Any ideas?

      Thanks!

      Miriam
        • 1. Re: Format ALL text fields?
          blemmo Level 1
          Hi,

          I didn't try to see if it really works, but maybe it's possible to use the prototype property to achieve this:
          if (_root.font == "Embed") {
          TextField.prototype.setTextFormat(embedFormat);
          TextField.prototype.embedFonts = true;
          }
          }
          This should affect all TextFields in the movie (if it affects anything...).

          Don't use onEnterFrame for this; the name is misleading: it executes repeatedly with the speed of the frame rate, so it's more like onFrameChange (but it also executes repeatedly if there's just 1 frame in the movie).
          So it would execute the code every X ms, depending on the frame rate. If you assign the code to frame 1, without onEnterFrame, it will execute when the playhead is on that frame, only once if the movie isn't looped. That's enough in this case.

          hth,
          blemmo
          • 2. Re: Format ALL text fields?
            NSurveyor Level 2
            I know the TextField.prototype.embedFonts = true; should work. But I don't think the other one will work...
            • 3. Re: Format ALL text fields?
              Miriam_McD Level 1
              Thank you both for your responses. Unfortunately, the prototype property didn't work. So, I'm still looking for suggestions...

              As far as onEnterFrame goes... I didn't think I would need it either, but my original code doesn't work without it.

              Miriam