2 Replies Latest reply on Feb 1, 2008 10:22 AM by zer0efx

    On click Increase/Decrease Font size

      Morning Everyone.

      I have a presentation that is filled from an XML file. All the text boxes are dynamic, loops go through and populate clips and what not.
      I want to add a function, that if they click on the big "A" it increases the Font size by 1 pt. so 12pt>13pt The little"a" would Decrease the font size. 13pt>12pt.

      To start, I just want to increase/decrease by 1 pt. but if later I can make it so each click increases/decreases that would be ideal.

      Not sure if this is possible, but I wanted to toss the question out there as I do my own research as well.

      Appreciate it!

        • 1. On click Increase/Decrease Font size
          robdillon Most Valuable Participant
          You can use the getTextFormat() method to retrieve the current formatting of any given textField. To get just the current font size, you can use this:

          var myTextFormat:TextFormat = textInstanceName.getTextFormat();
          var currentSize = myTextFormat["size"];

          Then you could create a new text format object to hold the new value:

          var newTextFormat:TextFormat = new TextFormat();

          and then set a new value for the size property of the new format:

          if (currentSize == 12) {
          newTextFormat.size = 13;
          } else {
          newTextFormat.size = 12;

          finally apply the new format to your textfield:

          since the only new information is the size, that's the only thing that will change.
          • 2. Re: On click Increase/Decrease Font size
            zer0efx Level 1
            Excellent!! Thanks for the reply! Very informative!

            I started already on it:

            var mySize:TextFormat = new TextFormat();
            mySize.size = 18;
            fontPlus.onRelease = function(){
            var my_fmt:TextFormat = item_mc.txtDocIntro.getTextFormat();

            Looks like I was on the right track, sorta.

            Thanks again!!