# Clearing text in an Input Text Field

**URL:** <https://forum.kirupa.com/t/clearing-text-in-an-input-text-field/185269>\
**Category:** flash\
**Created:** [April 12, 2006, 3:14am UTC](https://forum.kirupa.com/t/clearing-text-in-an-input-text-field/185269 "2006-04-12T03:14:17Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![vpmiyu](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/vpmiyu/32/1977_2.png) [@vpmiyu](https://forum.kirupa.com/u/vpmiyu)\
**Post date:** [April 12, 2006, 3:14am UTC](https://forum.kirupa.com/t/clearing-text-in-an-input-text-field/185269/1 "2006-04-12T03:14:17Z")

</div>

If I wanted to create a button that would clear all text a visitor has typed into a separate text box, named “page”, how would I do that? I’ve tried using the following actionscript on the button but to no avail:

on (release) {  
\_root.page = " ";  
}

---

<div class="post-metadata">

**Author:** ![matthewjumps](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@matthewjumps](https://forum.kirupa.com/u/matthewjumps)\
**Post date:** [April 12, 2006, 3:28am UTC](https://forum.kirupa.com/t/clearing-text-in-an-input-text-field/185269/2 "2006-04-12T03:28:20Z")

</div>

```auto

on (release) {
_root.page.text = " ";
}

```

---

<div class="post-metadata">

**Author:** ![vpmiyu](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/vpmiyu/32/1977_2.png) [@vpmiyu](https://forum.kirupa.com/u/vpmiyu)\
**Post date:** [April 12, 2006, 3:32am UTC](https://forum.kirupa.com/t/clearing-text-in-an-input-text-field/185269/3 "2006-04-12T03:32:13Z")

</div>

Hmm…that didn’t work either…?

That script should go with the button, yes?

---

<div class="post-metadata">

**Author:** ![matthewjumps](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@matthewjumps](https://forum.kirupa.com/u/matthewjumps)\
**Post date:** [April 12, 2006, 4:46am UTC](https://forum.kirupa.com/t/clearing-text-in-an-input-text-field/185269/4 "2006-04-12T04:46:49Z")

</div>

it works fine for me - post a fla or email it to me and i will try to fix it…before you do, double check all your instance naming, referencing and syntax, as there is no reason why \_root.page.text = " "; shouldnt work if the input textfield is really on the \_root. timeline and is called “page”.

---

<div class="post-metadata">

**Author:** ![vpmiyu](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/vpmiyu/32/1977_2.png) [@vpmiyu](https://forum.kirupa.com/u/vpmiyu)\
**Post date:** [April 12, 2006, 5:12pm UTC](https://forum.kirupa.com/t/clearing-text-in-an-input-text-field/185269/5 "2006-04-12T17:12:13Z")

</div>

[Here’s the file (kitties.fla)](http://www.pixelmiyu.com/fla/)

I want to make the star-like button at the top left clear the text field in the middle.

Maybe I’m having problems because the text field is in a movie clip? It works fine for another button I have that prints the text field (the piece of paper). But I’m fairly new at Actionscript so perhaps I’m missing something really basic… As far as I can tell everything is named correctly…

Thanks for your help on this!

---

<div class="post-metadata">

**Author:** ![neutrino](https://avatars.discourse-cdn.com/v4/letter/n/bb73d2/32.png) [@neutrino](https://forum.kirupa.com/u/neutrino)\
**Post date:** [April 12, 2006, 5:42pm UTC](https://forum.kirupa.com/t/clearing-text-in-an-input-text-field/185269/6 "2006-04-12T17:42:29Z")

</div>

i just looked at your FLA…

just use \_root.page.page.text

instead of \_root.page.text

That should work.

Good luck

---

<div class="post-metadata">

**Author:** ![neutrino](https://avatars.discourse-cdn.com/v4/letter/n/bb73d2/32.png) [@neutrino](https://forum.kirupa.com/u/neutrino)\
**Post date:** [April 12, 2006, 5:43pm UTC](https://forum.kirupa.com/t/clearing-text-in-an-input-text-field/185269/7 "2006-04-12T17:43:01Z")

</div>

when in doubt use the “target path” button from the Actions pane - that has saved me a lot of headaches…

---

<div class="post-metadata">

**Author:** ![matthewjumps](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@matthewjumps](https://forum.kirupa.com/u/matthewjumps)\
**Post date:** [April 12, 2006, 11:38pm UTC](https://forum.kirupa.com/t/clearing-text-in-an-input-text-field/185269/8 "2006-04-12T23:38:51Z")

</div>

did it work vpmiyu?

---

<div class="post-metadata">

**Author:** ![vpmiyu](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/vpmiyu/32/1977_2.png) [@vpmiyu](https://forum.kirupa.com/u/vpmiyu)\
**Post date:** [April 13, 2006, 12:06am UTC](https://forum.kirupa.com/t/clearing-text-in-an-input-text-field/185269/9 "2006-04-13T00:06:23Z")

</div>

Thanks for all your suggestions!

Actually, putting in page.page worked to clear the field when the swf was opened, but if I typed in words and then pressed the button, it didn’t clear them. Why woud that be?

---

<div class="post-metadata">

**Author:** ![matthewjumps](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@matthewjumps](https://forum.kirupa.com/u/matthewjumps)\
**Post date:** [April 13, 2006, 1:09am UTC](https://forum.kirupa.com/t/clearing-text-in-an-input-text-field/185269/10 "2006-04-13T01:09:08Z")

</div>

ok i renamed the input text inside the “page” movie clip to “textbox”. I also renamed the input text’s variable to “pageVar”.

it works fine using

```auto

on (release) {
	_root.page.textbox.text = "";
}

```

its not a good idea to use the same word for so many things, ie the movie clip called “page”, then you called the textbox inside it “page” again, then you called the variable for the textbox “page” again :crazy:

use descriptive instance naming :thumb:

---

<div class="post-metadata">

**Author:** ![vpmiyu](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/vpmiyu/32/1977_2.png) [@vpmiyu](https://forum.kirupa.com/u/vpmiyu)\
**Post date:** [April 13, 2006, 1:46am UTC](https://forum.kirupa.com/t/clearing-text-in-an-input-text-field/185269/11 "2006-04-13T01:46:57Z")

</div>

Ah hah! It works!

Thanks a ton. Next time I will use better naming! I had thought that if I named everything similar with that movie clip, it would make things easier. Heh. :ne: I guess that’s what you get when you’re new to actionscript!

Thanks to both of you for helpin me out! 😃

---

<div class="post-metadata">

**Author:** ![matthewjumps](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@matthewjumps](https://forum.kirupa.com/u/matthewjumps)\
**Post date:** [April 13, 2006, 2:29am UTC](https://forum.kirupa.com/t/clearing-text-in-an-input-text-field/185269/12 "2006-04-13T02:29:54Z")

</div>

:thumb: great! glad to be off assistance 😉
