5 Replies Latest reply on Nov 3, 2008 8:01 PM by sneakyimp

    propery way to load dynamic text which uses stylesheet and embedded fonts

    sneakyimp Level 2
      I have a dynamic text field with an instance name of txtFilmNews. I am loading some external HTML and an external stylesheet. I am also embedding fonts (Orator, regular and bold) for this text field. Everything seems to load properly -- html and stylesheets both -- however, the text shifts a tiny bit when I mouseover the hyperlinks in my text field.

      I'm wondering if this has something to do with how I've embedded my fonts. I created two new font objects in my library:
      DynamicFont1 - Orator 12 pt with linkage ID of DynamicFont1, exported for actionscript in first frame.
      DynamicFont1Bold - Orator 12 pt *bold* with linkage ID of DynamicFont1Bold, exported for actionscript in first frame.

      The stylesheet is here, NOTE that I refer to 'Orator' and not DynamicFont1 or whatever:
      http://merminfilm.com/styles.css

      The HTML is here:
      http://merminfilm.com/getHTML.php?q=filmNews

      The text does seem to appear with its regular and bold variants in various sizes and colors HOWEVER the text around the hyperlinks appears to jump when I mouseover the hyperlinks in the text. Interestingly, the jump only happens on the first mouseover and then the text is stable. What the heck? Is there some way to prevent this?

      Also, am I properly embedding my fonts and assiging stylesheets? I haven't been able to locate any authoritative adobe documentation on how to use stylesheets with embedded fonts in AS2. I have CS3 but am working on an older file.

      My code is below.
        • 1. Re: propery way to load dynamic text which uses stylesheet and embedded fonts
          chopTheWood
          Have you tried it without embedding fonts?
          • 2. Re: propery way to load dynamic text which uses stylesheet and embedded fonts
            chopTheWood Level 1
            I was just wandering if you still get the jump with no fonts imbedded
            • 3. Re: propery way to load dynamic text which uses stylesheet and embedded fonts
              sneakyimp Level 2
              I'm not sure how exactly to 'not embed' the font. Keep in mind that I'm using a stylesheet.

              I tried changing my style sheet to have a font family of 'sans-serif', '_sans', and 'Arial' yet in each case, I got a blank page -- no text was visible in my text field.

              I repeated those same font names after I changed my textfield inside my flash movie. I altered the textfield to have a default font of _sans, i set it to 'use device fonts'. I then repeated the font options above. nothing seemed to work. I think this is related to the use of a stylesheet.

              I also altered my stylesheet so that it did not specify any font-family information at all, this also resulted in a blank text field.

              I finally tried one last thing. I set the font of the textfield in cs3 to '_sans' and specifed 'DynamicFont1' or 'DynamicFont1Bold' in my stylesheet. This appears to have eliminated the problem. The jumping text problem appears to happen when I specify ANY embedded font in my dynamic text field in CS3 -- including one that I actually use in the text field. Weird.
              • 4. Re: propery way to load dynamic text which uses stylesheet and embedded fonts
                chopTheWood Level 1
                I noticed you have embed fonts=true in your script. Here's the way I did it that seemed to work:

                _root.createTextField("myFormattedText_txt",12,375,65,375,400);//depth 12
                myFormattedText_txt.type = "dynamic";
                myFormattedText_txt.border = false;
                myFormattedText_txt.textWidth = 400;
                myFormattedText_txt.background = false;
                myFormattedText_txt.multiline = true;
                myFormattedText_txt.html = true;
                myFormattedText_txt.selectable = false;
                myFormattedText_txt.wordWrap = true;
                myFormattedText_txt.scroll = true;
                var myCSS = new TextField.StyleSheet();
                myCSS.load("editText/edit.css");
                myCSS.onLoad = function() {
                myFormattedText_txt.styleSheet = myCSS;
                myFormattedText_txt.text = main_txt.text;
                };


                THE CSS IS AS FOLLOWS (example):

                body14 {
                font-family: Verdana,Arial,Helvetica,sans-serif;
                font-size: 14px;
                color:#000000;
                display: block;
                }

                bold {
                font-weight: bold;
                display: inline;
                }

                ------------------ the actual text without a SS applied to it looks like this:

                <body14><bold>Jeanne M. Thieme</bold> graduated from Southern Connecticut State College with a Bachelor of Science in Art Education. She began her art career in illustration and design in a Connecticut art studio. </body14>




                • 5. Re: propery way to load dynamic text which uses stylesheet and embedded fonts
                  sneakyimp Level 2
                  I only tried the embedFonts = true in an attempt to eliminate the text jumping around. I appreciate your example very much. I'll probably use that at some point. However, the need to use an embedded font is fairly critical for me in this file. The client really doesn't want the default fonts.

                  As I mentioned in my last post, the jumping text problem happens when I apply some font (even Arial will cause it) to the dynamic text field on my stage in CS3. Setting the text field's font to '_sans' seems to fix the problem -- and I am successfully using the Orator font which I have exported in my library.

                  Thanks again for your help. I really appreciate it.