Skip navigation
Currently Being Moderated

Dynamic Text: Gradually change font size as you type

Jun 26, 2012 10:22 AM

Still working on my project. I need some help with this.

 

I have a dynamic textbar connected to an onscreen keyboard, and I need the font to decrease in size depending on the number of characters you enter.

Seems like it could be a simple algorithm but I have no clue where to start.

any help?

 
Replies
  • Currently Being Moderated
    Jun 26, 2012 11:07 AM   in reply to tropicanaclock

    If you are using a textfield you can check its length property to know how many characters are in it.  To change the font size you'll need to use the TextFormat class and the setTextFormat() method of the TextField class.

     
    |
    Mark as:
  • kglad
    62,194 posts
    Jul 21, 2002
    Currently Being Moderated
    Jun 26, 2012 11:10 AM   in reply to tropicanaclock

    assign a textformat to your textfield and add a change listener to your textfield.  in the listener function adjust the textformat's size property per your needs and reassign the textformat to your textfield.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 26, 2012 1:39 PM   in reply to tropicanaclock

    If you are using an onscreen keyboard, I am not sure that a CHANGE listener will work if it involves adding text to the textfield with code... but kGlad will know better about that.  If it does involve code, whatever code adds text can have the task of checking the length right after each character is added. 

     

    To check the textfield's character count by its length property, basically use something similar to...

     

    numCharacters = yourTextfield.length;

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points