# Trace dynamic textfields

**URL:** <https://forum.kirupa.com/t/trace-dynamic-textfields/13424>\
**Category:** Uncategorized\
**Created:** [February 13, 2003, 3:32am UTC](https://forum.kirupa.com/t/trace-dynamic-textfields/13424 "2003-02-13T03:32:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![chapster](https://avatars.discourse-cdn.com/v4/letter/c/958977/32.png) [@chapster](https://forum.kirupa.com/u/chapster)\
**Post date:** [February 13, 2003, 3:32am UTC](https://forum.kirupa.com/t/trace-dynamic-textfields/13424/1 "2003-02-13T03:32:14Z")

</div>

How can you trace a dynamic textfield. I have a bunch of them inside movieclips.  
You can trace the name of a movie clip when you use code like this.

```auto

btn.onRollOver = function() {
trace(this._name);
};

```

btn is a variable with the path to all my dynamicaly made movieclips. But inside each of these dynamic movieclips is dynamicly created textfields with instance names. But I need a way to trace them how can this be done.  
I tried this but did not work.

```auto

btn.onRollOver = function() {
trace(this.text._name);
};

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 13, 2003, 5:48am UTC](https://forum.kirupa.com/t/trace-dynamic-textfields/13424/2 "2003-02-13T05:48:07Z")

</div>

**Anyone**

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 13, 2003, 6:19am UTC](https://forum.kirupa.com/t/trace-dynamic-textfields/13424/3 "2003-02-13T06:19:38Z")

</div>

Well I am not really sure what you are trying to do with that code.

Think about it…

\<B\>btn\</B\>.onRollOver = function() {  
trace(this.\_name);  
};

Well you already know the name because you had to target it right?

Same situation with the textbox.

btn.onRollOver = function() {  
trace(this.\<B\>myTextBox\</B\>.\_name);  
};

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 13, 2003, 1:06pm UTC](https://forum.kirupa.com/t/trace-dynamic-textfields/13424/4 "2003-02-13T13:06:15Z")

</div>

Ok here is what I have set up

```auto

for (var i = 0; i < dressArray.length; i++) {
btn = collectionMenu.CbuttHolder.createEmptyMovieClip(dressArray*+"_mc"+i, i);
btn.createTextField(dressArray*+"_txf", i, 0, 0, 90, 20);
name = btn[dressArray*+"_txf"];
btn._x = center;
btn._y = top+i*spaceY;
name.text = dressArray*;
name.setTextFormat(collectionFrm);
name.selectable = false;
btn.onRollOver = function() {
trace(this.text._name);
};
}

```

I need a way to find myTextfield that was why I was trying to use \_name.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 13, 2003, 1:10pm UTC](https://forum.kirupa.com/t/trace-dynamic-textfields/13424/5 "2003-02-13T13:10:49Z")

</div>

```auto

for (item in btn){
	if (btn[item] instanceof TextField) trace(item)
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 13, 2003, 1:16pm UTC](https://forum.kirupa.com/t/trace-dynamic-textfields/13424/6 "2003-02-13T13:16:13Z")

</div>

This is just giving me the last textfield that was made for every rollOver

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 13, 2003, 2:45pm UTC](https://forum.kirupa.com/t/trace-dynamic-textfields/13424/7 "2003-02-13T14:45:29Z")

</div>

What am I doing wrong. If I use what you sugested in my code. It will only trace the last created textfield in the first for loop.

```auto

for (var i = 0; i < dressArray.length; i++) {
btn = collectionMenu.CbuttHolder.createEmptyMovieClip(dressArray*+"_mc"+i, i);
btn.createTextField(dressArray*+"_txf", i, 0, 0, 90, 20);
name = btn[dressArray*+"_txf"];
btn._x = center;
btn._y = top+i*spaceY;
name.text = dressArray*;
name.setTextFormat(collectionFrm);
name.selectable = false;
btn.onRollOver = function() {
for (item in btn) {
if (btn[item] instanceof TextField) {
trace(item);
}
}
};
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 13, 2003, 3:09pm UTC](https://forum.kirupa.com/t/trace-dynamic-textfields/13424/8 "2003-02-13T15:09:03Z")

</div>

your textfields arent in the same movieclip, so instead you’ll have to go through each of the created movieclips and get the textfield out of them. Since you are putting them in their own movieclips, you wouldnt have to give them each a unique name since that is done through the movieclip their in. Then you just cycle through collectionMenu.CbuttHolder and snag the names of the textfields of the movieclips that have them (or just the names of the movieclip itself…) its really hard to say because you never really explained what you are trying to achieve

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 13, 2003, 3:18pm UTC](https://forum.kirupa.com/t/trace-dynamic-textfields/13424/9 "2003-02-13T15:18:54Z")

</div>

I want to change the text field color when you rollover the button.  
I need to do this without changing the color of the (btn) or mc itself so this is why I wanted when you rollover a button it finds its appropriate text field inside this btn and change the text field color.

> 

Then you just cycle through collectionMenu.CbuttHolder and snag the names of the text fields of the movie clips that have them (or just the names of the movie clip itself…) its really hard to say because you never really explained what you are trying to achieve

Well the first part of this quote is what I’m after. I can easily get the mc \_name but I need the text field inside the mc.  
Thanks for your patience.
