# Clearing Text From Text Input Component

**URL:** <https://forum.kirupa.com/t/clearing-text-from-text-input-component/261702>\
**Category:** flash\
**Created:** [May 30, 2008, 1:14am UTC](https://forum.kirupa.com/t/clearing-text-from-text-input-component/261702 "2008-05-30T01:14:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bdq172](https://avatars.discourse-cdn.com/v4/letter/b/3ab097/32.png) [@bdq172](https://forum.kirupa.com/u/bdq172)\
**Post date:** [May 30, 2008, 1:14am UTC](https://forum.kirupa.com/t/clearing-text-from-text-input-component/261702/1 "2008-05-30T01:14:32Z")

</div>

I have a text input component on stage and a button next to it. I want to clear any text that’s entered when the button is clicked. Here’s what I’ve got so far. Thanks for any help.

tf.addEventListener(TextEvent.TEXT\_INPUT, onTextInput);  
function onTextInput(e:TextEvent):void {  
//need some code to clear tf

}

---

<div class="post-metadata">

**Author:** ![rbnzdave](https://avatars.discourse-cdn.com/v4/letter/r/a587f6/32.png) [@rbnzdave](https://forum.kirupa.com/u/rbnzdave)\
**Post date:** [May 30, 2008, 1:38am UTC](https://forum.kirupa.com/t/clearing-text-from-text-input-component/261702/2 "2008-05-30T01:38:13Z")

</div>

```auto
myButton.addEventListener(MouseEvent.MOUSE_UP,clearBoxFunction);

function clearBoxFunction(e:MouseEvent):void {
   e.target.parent.myTextInput.text = "";
}

```

---

<div class="post-metadata">

**Author:** ![mcq172](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@mcq172](https://forum.kirupa.com/u/mcq172)\
**Post date:** [May 30, 2008, 1:59am UTC](https://forum.kirupa.com/t/clearing-text-from-text-input-component/261702/3 "2008-05-30T01:59:16Z")

</div>

I modified the code you gave me and now it works great!

> [@rbnzdave;2333371](#):
>
> ```auto
> myButton.addEventListener(MouseEvent.MOUSE_UP,clearBoxFunction);
>  
> function clearBoxFunction(e:MouseEvent):void {
> e.target.parent.myTextInput.text = "";
> }
> 
> ```
