# Attaching text to an animated sprite?

**URL:** <https://forum.kirupa.com/t/attaching-text-to-an-animated-sprite/277978>\
**Category:** flash\
**Created:** [December 19, 2008, 3:31pm UTC](https://forum.kirupa.com/t/attaching-text-to-an-animated-sprite/277978 "2008-12-19T15:31:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![juniorspecial](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/juniorspecial/32/2610_2.png) [@juniorspecial](https://forum.kirupa.com/u/juniorspecial)\
**Post date:** [December 19, 2008, 3:31pm UTC](https://forum.kirupa.com/t/attaching-text-to-an-animated-sprite/277978/1 "2008-12-19T15:31:37Z")

</div>

I’m doing something wrong, but I don’t know what.I have a basic rectangle that is animated [moveBasicRect()]. I want to attach a textBox to it, so that when the animated rectangle moves, the text moves with it.

But when I use this code, the textBox just sits there, and the rectangle moves out from underneath it. How do I get the textBox to stick to the moving rectangle?

package {  
import flash.display.Sprite;

```
public class moveBasicTextRect extends Sprite {
	
	var r:moveBasicRect = new moveBasicRect();
	var rTxt:textBox = new textBox();
	public function moveBasicTextRect() {
		
	addChild(r);
	r.addChildAt(rTxt,1);

	}
}

```

}
