2 Replies Latest reply on Sep 17, 2009 10:48 PM by MediaMackenzie.com

    Centering text weirdness - please help!




      Please check out my newest site: http://www.catherinemix.com


      It is cool and I'm am happy with it, but there is still just one bug I would like to work out:


      Notice, when u click on a thumbnail and make a full size image appear, that the descriptive info at the bottom of the screen often trends toward the left a bit. I have no idea why this occurs. Here is the code involved:


              titleText = new TextField();
              titleText.autoSize = TextFieldAutoSize.CENTER;


              var ttFormat:TextFormat = new TextFormat();
              ttFormat.color = 0xFFFFFF;
              ttFormat.size = 18;
              ttFormat.font = "Baskerville Old Face";


              textSprite = new Sprite();
              (parent  as  MovieClip).addChild(textSprite);
              var titleXML:XML = new XML(titleURL.data);




              titleText.text = titleXML.toXMLString();
              textSprite.y = 570;
              textSprite.x = ((stage.stageWidth / 2) - titleText.length);
              trace("titleText.length = " + titleText.length);
              trace("titleText.x = " + titleText.x);
              textSprite.mouseEnabled = false;
              titleText.mouseEnabled = false;


      I dunno... Anyone see a flaw in my thinking / code?


      Thx and Be Well!


        • 1. Re: Centering text weirdness - please help!
          Ned Murphy Adobe Community Professional & MVP

          You are uusing the TextField length property as part of your centering scheme.  That value represents the number of characters in the text field, not the physical length of it.  You might do better using the textWidth property instead.  Or you might just be able to use the textSprite width property.  To center it would be the half the stage width minus 1 half the textfield width.


          Since you are trying to apply a text format to the textfield, you may want to consider using a textfield planted on the sage permanently rather than creating it dynamically.  That way you can embed the font so that the intended font is seen by the viewer and not whatever default their system will apply--mine appears to be Times New Roman.  Having the textfield already there (at the width of the stage) will allow exact centering.

          • 2. Re: Centering text weirdness - please help!
            MediaMackenzie.com Level 1

            Thank you for your assistance. It was very helpful, especially in cluing me in to the fact that my dynamically created text wasn't embedding. I think it is now tho: http://www.catherinemix.com


            Thanks Again,