0 Replies Latest reply on Aug 3, 2006 9:42 PM by Metzen2K

    Dynamic Fonts - So close!

    Metzen2K
      I'm designing a header builder so that my clients can build their own Flash headers from a web form, the results of which are passed to an .swf and images and text are loaded / created based on the input.

      Everything works except the embedded fonts.

      I found this code from "the fleece", which works when you press a button:

      var font_mc:MovieClip = this.createEmptyMovieClip("font", 1);
      font_mc.loadMovie("fonts/myFont.swf");

      myButton.onRelease = function() {
      var txt_mc:TextField = font_mc.createTextField("txt", 1, 0, 0, 150, 20);
      txt_mc.embedFonts = true;
      txt_mc.text = "testing";

      var my_fmt:TextFormat = new TextFormat();
      my_fmt.font = "myFont";
      txt_mc.setTextFormat(my_fmt);
      };

      In a Flash Player 7 file I had to change the first 2 lines of the function so that it would run:
      font_mc.createTextField("txt", 1, 0, 0, 150, 20);
      var txt_mc:TextField = font_mc.txt;

      With the button press it still works.

      How can I get the code to be run on something other than a button press?

      Everything happens in one movie, in one frame, with the exception of the external font .swf's, which are each one movie, one frame.

      Also, how can I make the "font_mc" in these lines variable:

      var font_mc:MovieClip = this.createEmptyMovieClip("font", 1);
      font_mc.loadMovie("fonts/myFont.swf");

      Instead of "font_mc" I want to be able to name the new movie clip after the font, since I'll need to load different font files based on which fonts the user chooses. I'd like to have an importFont() function and pass the movie clip name in as an argument.

      Thanks!