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 6787103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:19:33+00:00 2026-05-26T17:19:33+00:00

I am trying to get some words from xml and put them an the

  • 0

I am trying to get some words from xml and put them an the stage side by side in the center of the stage. I achieved this by the code below. I auto resize textfield according to text inside. But this time there comes space between words. What I accomplish is to have autoresized and adjacent words without space between them. But I could not solve the problem.
Could you please help me to solve it.
Thanks in advance

                var partsWidth=100;              
                var wordTf = new TextField();
                wordTf.name =thispart;
                wordTf.text =thispart;
                wordTf.width=partsWidth;
                xStartPoint=stage.stageWidth / 2  -  (numberOfWords * partsWidth )/2;
                wordTf.height=partsHeight;
                wordTf.x= xStartPoint + (index * partsWidth) ;
                wordTf.y=150;
                wordTf.background=true;
                wordTf.backgroundColor = 0xe3e3e3;

                wordTf.border = true;
                var myFormat:TextFormat = new TextFormat();
                    myFormat.size = 16;
                    myFormat.align = TextFormatAlign.CENTER;

                wordTf.setTextFormat(myFormat);
                wordTf.autoSize=TextFieldAutoSize.CENTER;
                addChild(wordTf);
  • 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-26T17:19:33+00:00Added an answer on May 26, 2026 at 5:19 pm

    you are setting the width explicit with wordTf.width=partsWidth;. this will override the autosize option. I would use the following code.

    var container:Sprite = new Sprite();
    
    var myFormat:TextFormat = new TextFormat();
        myFormat.size = 16;
        myFormat.align = TextFormatAlign.CENTER;
    
    for each( var thispart:String in parts ) 
    {
        var wordTf = new TextField();
        wordTf.defaultTextFormat = myFormat;
        wordTf.name = thispart;
        wordTf.text = thispart;
        wordTf.height=partsHeight;
        wordTf.background=true;
        wordTf.backgroundColor = 0xe3e3e3;
        wordTf.border = true;
        wordTf.width = wordTf.textWidth + 4;
        wordTf.y=150;
        wordTf.x = container.width;
        container.addChild(wordTf);
    }
    
    container.x = (stage.stageWidth - container.width) / 2;
    addChild(container);
    

    add your words to a separate sprite, and after all words added, add this sprite to the stage and center it.

    The line

    wordTf.width = wordTf.textWidth + 4;
    

    is the important one. After setting the text, flash can calculate the width of the text. now set this text width (+4 is a fixed padding around the text in a text field you can’t modify) as width of your textfield.

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

Sidebar

Related Questions

I am trying to get some XML data with LINQ, but running into a
I'm trying to get some code working that a previous developer has written. Yep,
I am trying to get some xpath from xsl variable using xsl ver 1.0
I'm trying to write a unit test that checks some xml parsing code. The
I am trying to display some xml data from remote URL using jquery and
I am trying to parse a xml from some source and store the results
I'm trying to parse some XML from the USGS. Here's an example The parameterCd
I'm trying to make a request using dojo.xhrGet to grab some XML data from
I'm trying to parse some XML I've gotten from the Google Data Booksearch API
I am trying to extract some data from XML but when I execute the

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.