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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:41:28+00:00 2026-05-12T18:41:28+00:00

I’m adding an array of sprites, each with an associated textfield. When the sprite

  • 0

I’m adding an array of sprites, each with an associated textfield.

When the sprite is clicked (or the textfield — either one, though I want the cursor to be a hand) all I want to do is to grab the text. (e.g. “One” in the example below).

It ought to be possible to do it with dot notation, using the sprite’s name, but that doesn’t work. That is, Sprite_1.textField_1.text doesn’t work.

When I click the sprite, I can add an event listener, but the target is then the sprite, and the sprite object does not contain the textfield object.

Extremely frustrating and ought to be simple… anyone know how to do this?

for (var i : int = 0;i < 5; i++) 
{
 var myText:TextField = new TextField();
 myText.text = someText;
   //say "One" first time through, then "Two" second time thru, etc.  
 myText.name = "textField_" + i;
 mySprite.addEventListener(MouseEvent.CLICK, grabText); 

 var mySprite:Sprite = new Sprite();
 mySprite.graphics.lineStyle(2,0x000000);
 mySprite.graphics.beginFill(0xff0000, 1);
 mySprite.graphics.drawRect(0, 0, myText.width, myText.height);
 mySprite.graphics.endFill();
 mySprite.useHandCursor = true;
 mySprite.mouseChildren = false;
 mySprite.buttonMode = true;
 mySprite.name = "Sprite_" + i;
 mySprite.addEventListener(MouseEvent.CLICK, grabText);

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-05-12T18:41:29+00:00Added an answer on May 12, 2026 at 6:41 pm

    You haven’t given the full code and it’s not clear if you are addChilding textfield to mySprite or mySprite to this. Assuming that you are doing it, you can use getChildByName method to access them (I would rather store them in arrays and access from there – but that might take a lot of redesigning). Be warned that getChildByName returns the first child with a matching name and hence fails for cases where there are multiple children with the same name.

    var sprite:Sprite = Sprite(this.getChildByName("Sprite_1"));
    var tf:TextField = TextField(sprite.getChildByName("textField_1"));
    tf.text = "some other text";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 366k
  • Answers 366k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have look at http://swit.kornr.net/ Its for Wicket, but perhaps it… May 14, 2026 at 4:28 pm
  • Editorial Team
    Editorial Team added an answer Havn't you read the example (contained in the dist) and… May 14, 2026 at 4:28 pm
  • Editorial Team
    Editorial Team added an answer Sound equivalent of OpenGL is OpenAL library. It is cross-platform,… May 14, 2026 at 4:28 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.