14 Replies Latest reply on Oct 5, 2010 5:19 AM by Ned Murphy

    Dynamic textField

    Ron Colmen Level 2

      What are the methods to make fonts in a Dynamic textFields more sharper?

       

      This code won't show the text field using the embed font type?

       

      this.createTextField("scroll_txt", this.getNextHighestDepth(), 0, 0, 0, 0);

      this.createTextField("newszlatest", this.getNextHighestDepth(), 556, 170, 355, 290);

      newszlatest.multiline = true;

      newszlatest.wordWrap = true;

      newszlatest.textColor = 0xFFFFFF;

      //newszlatest.embedFonts = true;

      newszlatest.font = Font1;

      //newszlatest._rotation = 45;

        • 1. Re: Dynamic textField
          Ned Murphy Adobe Community Professional & MVP

          I believe fonts are set using the setTextFormat method, not as a property of the textfield.  Look up the embedFonts property for an example.

          • 2. Re: Dynamic textField
            A.kameshwaran

            Hi

                 I think this will help you.

             

            var format:TextFormat = new TextFormat();
            format.font = "Arial";
            format.color = 0x00FFFF;
            format.size = 20;
            newszlatest.setNewTextFormat(format);

             

            cheers...(-_-)

            • 3. Re: Dynamic textField
              Ron Colmen Level 2

              hi kameshwaran - I'm trying to use the embed font not a system font.

              • 4. Re: Dynamic textField
                Ron Colmen Level 2

                Hi Ned... This is my script. I don't know why can't I make my embed font apply.

                 

                var format1:TextFormat = new TextFormat();

                format1.bold = true;

                format1.color = 0xC0C0C0;

                format1.size = 12

                 

                var formatA:TextFormat = new TextFormat();

                formatA.font = Font1";

                formatA.color = 0xFF0000;

                formatA.size = 11;

                 

                this.createTextField("scroll_txt", this.getNextHighestDepth(), 0, 0, 0, 0);

                this.createTextField("newszlatest", this.getNextHighestDepth(), 556, 170, 355, 290);

                newszlatest.multiline = true;

                newszlatest.wordWrap = true;

                newszlatest.setNewTextFormat(formatA);

                //newszlatest._rotation = 45;

                senderLoad.sendAndLoad("http://www.abc.com/my.php,receiveLoad,"POST");

                 

                receiveLoad.onData = function(src) {

                     var messageA:Array = src.split(",,,");

                     messageA.pop();

                var charCount = 0;

                     var formatIndices = new Array();

                newszlatest.html=true;

                     for(var i:Number=0; i<messageA.length; i++){

                           var msgA:Array = messageA[i].split(",,");

                           newszlatest.htmlText +=msgA[1].split(" ")[0]+"  "+msgA[0]+"<br>"+msgA[2]+"<\a><br><br>";

                           formatIndices[i] = {startAt: charCount, endAt: charCount+msgA[1].length};

                           charCount = newszlatest.text.length;

                     }

                     for(var j:Number=0; j<formatIndices.length; j++){

                           newszlatest.setTextFormat(formatIndices[j].startAt, formatIndices[j].endAt, format1);

                     }

                };

                 

                 

                fontBox.JPG

                • 5. Re: Dynamic textField
                  A.kameshwaran Level 1

                  Hi Ron,

                     It will work. Please tell me how did you embed the font.

                  • 6. Re: Dynamic textField
                    A.kameshwaran Level 1

                    Hi Ron,

                     

                    Just take one sample fla and try the below steps. If you have done the below things not a problem.

                     

                    1. In Library right click and select “New Font”.

                    2. Right-click and choose “linkage”. select the option export for actionscript. Give name us my_font.

                    3.  “my_font*” will appear in the font drop down of the  TextField properties window. When choosing this font. The embedded font  is used.

                     

                    now,

                    Keep the text box in the stage and have some other font type for that. Then, also have a button and give a name as test_btn to check weather it is working. In that type the below code and check weather it is working or not.

                     

                    test_btn.onPress = function()
                    {
                        var format:TextFormat = new TextFormat();
                        format.font = "kamesh"; // kamesh is the embed font
                        format.color = 0x000000;
                        format.size = 20;
                        newszlatest.setNewTextFormat(format);
                    };

                     

                    I hope it will help you.

                    • 7. Re: Dynamic textField
                      Ned Murphy Adobe Community Professional & MVP

                      I don't see a line indicating to embed the font before you assign the text format... as in...

                       

                      newszlatest.embedFonts = true;

                       

                      and try using setTextFormat instead of setNewTextFormat...

                       

                      newszlatest.setTextFormat(formatA);

                      1 person found this helpful
                      • 8. Re: Dynamic textField
                        Ron Colmen Level 2

                        Thanks Ned.
                        When I put newszlatest.embedFonts = true; there is a warning. What's the reason for this warning?

                         

                        warning.JPG

                        • 9. Re: Dynamic textField
                          Ned Murphy Adobe Community Professional & MVP

                          Try setting up the textfield code separately in a test file without the inclusion of the data file being read (just use some line of text instead), and see if the warning still occurs.  If so, show the code you are using in the test file.

                          • 10. Re: Dynamic textField
                            Ron Colmen Level 2

                            As you suggested when I use it in another text field it works perfectly and no warnings.

                             

                            Why isn't it applying to my newszlatest textField?

                            • 11. Re: Dynamic textField
                              Ron Colmen Level 2

                              I realized that when I remove this code it works (I use this to create a line at the bottom of each record). Any idea why is that?

                               

                              function hrF(tf:TextField,char:String,color:Number):String{

                                  var htmlS:String = tf.htmlText;

                                  var newlineS:String = "";

                                  if(tf.maxscroll==1){

                                      var initialBottomScroll:Number = tf.bottomScroll;

                                      while(tf.bottomScroll==initialBottomScroll && tf.maxscroll==1){

                                          newlineS += char;

                                          tf.htmlText = htmlS+newlineS;

                                      }

                                      newlineS = newlineS.substring(0,newlineS.length-2);

                                      tf.htmlText = htmlS;

                                      return "<font color='#"+color.toString(16)+"'>"+newlineS+"</font>";

                               

                                  } else {

                                      tf.htmlText = htmlS+char;

                                      var initialMaxScroll:Number = tf.maxscroll;

                                      while(tf.maxscroll==initialMaxScroll){

                                          newlineS += char;

                                          tf.htmlText = htmlS+newlineS;

                                      }

                                      newlineS = newlineS.substring(0,newlineS.length-2);

                                      tf.htmlText = htmlS;

                                      return "<font color='#"+color.toString(16)+"'>"+newlineS+"</font>";

                                  }

                              }

                              • 12. Re: Dynamic textField
                                Ned Murphy Adobe Community Professional & MVP

                                Anytime you get a message about a script running on and on, you need to look in your code for elements that can make that

                                happen.  "while" loops are notorious for that... operating until a condition no longer exists.  Check the values of your conditions to see if/why the loops are not ending.

                                • 13. Re: Dynamic textField
                                  Ron Colmen Level 2

                                  Fixed it!! Thanks Ned.

                                  • 14. Re: Dynamic textField
                                    Ned Murphy Adobe Community Professional & MVP

                                    You're welcome