# Problem accessing dynamic text in a dynamically created movielcip

**URL:** <https://forum.kirupa.com/t/problem-accessing-dynamic-text-in-a-dynamically-created-movielcip/319979>\
**Category:** flash\
**Created:** [March 10, 2011, 8:06am UTC](https://forum.kirupa.com/t/problem-accessing-dynamic-text-in-a-dynamically-created-movielcip/319979 "2011-03-10T08:06:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonicboy](https://avatars.discourse-cdn.com/v4/letter/t/e19adc/32.png) [@tonicboy](https://forum.kirupa.com/u/tonicboy)\
**Post date:** [March 10, 2011, 8:06am UTC](https://forum.kirupa.com/t/problem-accessing-dynamic-text-in-a-dynamically-created-movielcip/319979/1 "2011-03-10T08:06:35Z")

</div>

Hey guys,

So I created a movieclip and linked it to a class called CustomButton. Inside the movie clip is a text field with name **btnText**. I then created a few buttons with this code:

```auto
	var newBtn:CustomButton = new CustomButton();
	
	// set properties of new button
	newBtn.x = INIT_X;
	newBtn.y = INIT_Y + (INIT_H*i);
	newBtn.btnText.text = myText;
	
	this.addChild(newBtn);

```

So far, so good. Everything works ok and the code sets the text of the new movieclip. Now, I wanted to actually write the CustomButton class and add some properties and eventually do other stuff with it and so I wrote this:

```auto
package
{
	import flash.display.MovieClip;

	public class CustomButton extends MovieClip
	{
		public var btnText:String;
		public var url:String;
		public var desc:String;

		public function CustomButton()
		{
			
		}

	}
}

```

On trying my script again, it gives me this error:

```auto
1119: Access of possibly undefined property text through a reference with static type String

```

the line of code it refers to is:

```auto
newBtn.btnText.text = text;

```

Any clues?
