Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 617939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:29:24+00:00 2026-05-13T18:29:24+00:00

I’m aware of textAlign property of the Text component. But it doesn’t do what

  • 0

I’m aware of textAlign property of the Text component. But it doesn’t do what I’m trying to achieve:

I have a Text component which is 500×100 (the size does not change). The default font size is 80 px. The text, however, keeps changing. What I want is to resize the text to “fit” inside the textfield.

Let’s say the text is changed to: “A quick brown fox jumped over the lazy dog”. That would not fit inside the textfield, because the font size is too big. So how can the textsize be shrinked so that everything fits and nothing goes to the next line?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:29:24+00:00Added an answer on May 13, 2026 at 6:29 pm

    Here you go (directly from Adobe):

    Given a width in pixels and a maximum number of lines to display, the HeadlineTextField alters the font size to make the text fit the field. If the text is short the font size will be very large, creating a tabloid-style headline. If the text is long the font size will of course be smaller.

    The HeadlineTextField.fitText() method shown below does the font sizing work:

    public function fitText(msg:String, maxLines:uint = 1, toUpper:Boolean = false, targetWidth:Number = -1):uint
    {
        this.text = toUpper ? msg.toUpperCase() : msg;
    
        if (targetWidth == -1)
        {
            targetWidth = this.width;
        }
    
        var pixelsPerChar:Number = targetWidth / msg.length;
    
        var pointSize:Number = Math.min(MAX_POINT_SIZE, Math.round(pixelsPerChar * 1.8 * maxLines));
    
        if (pointSize < 6)
        {
            // the point size is too small
            return pointSize;
        }
    
        this.changeSize(pointSize);
    
        if (this.numLines > maxLines)
        {
            return shrinkText(--pointSize, maxLines);
        }
        else
        {
            return growText(pointSize, maxLines);
        }
    }
    
    public function growText(pointSize:Number, maxLines:uint = 1):Number
    {
        if (pointSize >= MAX_POINT_SIZE)
        {
            return pointSize;
        }
    
        this.changeSize(pointSize + 1);
    
        if (this.numLines > maxLines)
        {
            // set it back to the last size
            this.changeSize(pointSize);
            return pointSize;
        }
        else
        {
            return growText(pointSize + 1, maxLines);
        }
    }
    
    public function shrinkText(pointSize:Number, maxLines:uint=1):Number
    {
        if (pointSize <= MIN_POINT_SIZE)
        {
            return pointSize;
        }
    
        this.changeSize(pointSize);
    
        if (this.numLines > maxLines)
        {
            return shrinkText(pointSize - 1, maxLines);
        }
        else
        {
            return pointSize;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a reasonable size flat file database of text documents mostly saved in
I am trying to understand how to use SyndicationItem to display feed which is
I have a French site that I want to parse, but am running into
I have an autohotkey script which looks up a word in a bilingual dictionary
This could be a duplicate question, but I have no idea what search terms
I have an array which has BIG numbers and small numbers in it. I
I'm trying to select an H1 element which is the second-child in its group
I have a bunch of posts stored in text files formatted in yaml/textile (from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.