1 Reply Latest reply on Nov 8, 2010 5:16 PM by Ned Murphy

    Global textFormat?

    celebritymusic Level 1



      I have a few textFields throughout my project, which often need the same textFormat.  However, because they are on different timelines, I'm unsure how to have the textFormat object in one place so they can all access it.


      Should it be an external class, and if so, how do you access it?:


      mySuperTextfield.setTextFormat(????what goes here?????);





        • 1. Re: Global textFormat?
          Ned Murphy Adobe Community Professional & MVP

          One way is to create a global class file and use that for any global things you want to establish.  Here's one version I've seen for such a class file (named global.as)...


          public const global:Object = new Object();


          In your fla file you could establish the text format on the main timeline using....


          import global;


          global.tFormat = new TextFormat();
          global.tFormat.font = "Papyrus";
          global.tFormat.size = 46;
          global.tFormat.color = 0xFF0000;


          Then, anywhere (any timeline) within the file where you have a textfield that you want to establish a text format for you could use...


          tf.defaultTextFormat = global.tFormat;   // before text is assigned


          tf.setTextFormat(global.tFormat);   // after text is assigned