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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:47:14+00:00 2026-06-18T06:47:14+00:00

Really need some help understanding whats going on after textFields[i].text = thisWord.charAt(i); I understand

  • 0

Really need some help understanding whats going on after

textFields[i].text = thisWord.charAt(i);

I understand it updates a value at that particular index, I just can’t figure out why it affects:

textContainer.addChild(tempText);
textFields.push(tempText);

The value that gets changed appears on the stage but I don’t understand why because it’s never added as a child of textContainer.

var loader:URLLoader;
var allWords:Array;
var thisWord:String;

var textContainer:MovieClip;

var textFields:Array;
var textStyle:TextFormat;
var underline:MovieClip;

function init():void
{
    loader = new URLLoader();
    allWords = new Array();

    textContainer = new MovieClip();
    textFields = new Array();

    textStyle = new TextFormat();
    textStyle.font = "Courier New";
    textStyle.size = 48;
    textStyle.bold = true;

    textContainer.y = stage.stageHeight / 2 - 50;
    addChild(textContainer);

    loader.load(new URLRequest("words.txt"));
    loader.addEventListener(Event.COMPLETE, textLoaded);
    guess_btn.addEventListener(MouseEvent.CLICK, guess);

}

function textLoaded(event:Event):void
{
    var tempText:TextField;

    var stringOfWords:String = event.target.data;
    allWords = stringOfWords.split(",");
    thisWord = allWords[Math.floor(Math.random() * allWords.length)];
    trace(thisWord);

    for (var i:uint = 0; i < thisWord.length; i++)
    {
        tempText = new TextField();
        tempText.defaultTextFormat = textStyle;
        tempText.name = "textField" + i;
        tempText.text = "1";//for restart

        tempText.width = 48;
        tempText.x = i * tempText.width;
        tempText.selectable = false;
        textContainer.addChild(tempText);

        textFields.push(tempText);

        if (thisWord.charAt(i) != " ")
        {
            underline = new Underline();
            underline.x = tempText.x + tempText.width / 3;
            underline.y = tempText.y + tempText.height / 2 + 5;
            //textContainer.addChild(underline);
        }
    }

    textContainer.x = stage.stageWidth / 2 - textContainer.width / 2;



}

function guess(event:MouseEvent):void
{
    if (guess_txt.text != "")
    {
        if (thisWord.indexOf(guess_txt.text) != -1)
        {
            for (var i:uint = 0; i < textFields.length; i++)
            {
                if (thisWord.charAt(i) == guess_txt.text)
                {
                    textFields[i].text = thisWord.charAt(i);
                    trace(textFields[i].text);
                }
            }

        }
        else if (guesses_txt.text == "")
        {
            guesses_txt.appendText(guess_txt.text);
        }
        else
        {
            guesses_txt.appendText("," + guess_txt.text);
        }
    }

    guess_txt.text = "";
    findch();
}

init();

I’m pretty sure theres a rule I’m missing or not understanding….

Thanks.

  • 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-06-18T06:47:15+00:00Added an answer on June 18, 2026 at 6:47 am

    You pointed out right in your question that it actually is being added. Each tempText object you create in that loop is added to textContainer which had been added to stage in the constructor.

    textContainer.addChild(tempText);
    

    textFields[i].text = thisWord.charAt(i); is just updating the text of the TextField at the specific index within the array. There is no reason the text on the stage should not be updating here.

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

Sidebar

Related Questions

I really need some help in Regular Expressions, i'm working on a function like
I really need some help with this as I have been trying to fix
We Really need some help on this one: We've Struggled with all the Apple
I'm new to java and really need some help. I created a command line
I'm new to MySQL so I really need some help with an issue I'm
Okay, I really need some help with this. I'm new with designing and stuff,
I need some help in figuring a compiler error which is really driving me
I'm confused about how DQL works, and really need some help here. I have
I really need some help solving this little puzzle in my app. Case: I
I really need some help with a leak I get while switching from one

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.