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

  • Home
  • SEARCH
  • 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 4615342
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:49:35+00:00 2026-05-22T01:49:35+00:00

I’ve created a dynamic text field, and set autoSize to true, so it can

  • 0

I’ve created a dynamic text field, and set autoSize to true, so it can grow was tall as necessary. I then want to use the _height value to size a container graphic (speech bubble).

Here’s the (simplified) code:

var format:TextFormat = new TextFormat("Arial", 14);
format.color = 0x000000;
format.letterSpacing = -0.2;

var txt:TextField = _root.createTextField("dialog_txt", 150, 10, 10, 150, 0);
txt.multiline = true;
txt.wordWrap = true;
txt.autoSize = 'left';
txt.embedFonts = true;
txt.selectable = false;
txt.text = value;
txt.setTextFormat(format);

I then try to set my container’s height to the height of the textfield + 5, but it comes out way too short.

container._height = txt._height + 5;

I found that by adding trace(txt._height) before, the values come out right, even though the trace value is too small. Even just assigning the txt._height to a temp variable (var junk=txt._height;) fixes the problem. Replacing that with a couple trace functions:

trace(txt._height); //Note: No code between these two calls
trace(txt._height);

Returns 19.6 followed immediately by 35.2. It’s as though reading txt._height causes it to recalculate, so it’s correct the second time.

I also tried the textHeight property, which also seems to get recalculated after _height is accessed. This sequence, for example:

trace(txt.textHeight); // Returns 15
trace(txt.textHeight); // Returns 15
trace(txt._height);    // Returns 19.6
trace(txt.textHeight); // Returns 31
trace(txt._height);    // Returns 35.2

This is in AS 2, being compiled by MTASC.

Any ideas on what’s going on here?

  • 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-22T01:49:35+00:00Added an answer on May 22, 2026 at 1:49 am

    First off, you need to clarify that you are using AS2. I take it that means you are running Flash 8 or something along those lines (AS3 uses .height, AS2 uses ._height)?

    What could be happening is the calculation only happens on a new frame. Did you try using something like setTimeout() to call your resize code later or dispatchEvent to do the resizing?

    From my experience autosize never did run well. You are much better off creating a class that extends Textfield and write your own text function that calls the super, then expands the height of the textfield to _textHeight. This value should be correct the first time with autosize off.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to parse a xhtml file and display in UITableView. what is the
I need to clean up various Word 'smart' characters in user input, including but
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

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.