# Button open/close text field

**URL:** https://forum.kirupa.com/t/button-open-close-text-field/264819
**Category:** Uncategorized
**Created:** [June 30, 2008, 10:07pm UTC](https://forum.kirupa.com/t/button-open-close-text-field/264819 "2008-06-30T22:07:36Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![drakkonblade](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@drakkonblade](https://forum.kirupa.com/u/drakkonblade)
#### Post date: [June 30, 2008, 10:07pm UTC](https://forum.kirupa.com/t/button-open-close-text-field/264819/1 "2008-06-30T22:07:36Z")

</div>

**i dont know if this solvable via flash cs3 section or its a as3 issue…**

well i still a newb on the learning curve of as3…i would appreciate and great full  
to those that can help me with this…

i know and did the buttons for the text fields…  
i did most of the work just it ain’t working like expected so hoping for information on how to solve this puzzle…

i want my button when pressed to open a text box in current frame; but when i press it again the same button that it closes it.

thank you very much for assistance

---

<div class="post-metadata">

### Author: ![drakkonblade](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@drakkonblade](https://forum.kirupa.com/u/drakkonblade)
#### Post date: [July 1, 2008, 12:37am UTC](https://forum.kirupa.com/t/button-open-close-text-field/264819/2 "2008-07-01T00:37:12Z")

</div>

10+ views please if know anything that can lead me to answer please tell me. any help even from newbs be much appreciated …we all started from somewhere…

thanks again

---

<div class="post-metadata">

### Author: ![drakkonblade](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@drakkonblade](https://forum.kirupa.com/u/drakkonblade)
#### Post date: [July 1, 2008, 1:40am UTC](https://forum.kirupa.com/t/button-open-close-text-field/264819/3 "2008-07-01T01:40:32Z")

</div>

a followup to what you asked.

what i am trying to do is as follows…

i have a button with the 3 statuses up/over/down…when i press it a textbox appears…  
when i press it again then it vanishes

thank you please confirm on this asc3 to make it happen

---

<div class="post-metadata">

### Author: ![drakkonblade](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@drakkonblade](https://forum.kirupa.com/u/drakkonblade)
#### Post date: [July 1, 2008, 11:32am UTC](https://forum.kirupa.com/t/button-open-close-text-field/264819/4 "2008-07-01T11:32:04Z")

</div>

anyone willing to view and share their wisdom to this…

thank you

---

<div class="post-metadata">

### Author: ![Iamthejuggler](https://avatars.discourse-cdn.com/v4/letter/i/ecc23a/32.png) [@Iamthejuggler](https://forum.kirupa.com/u/Iamthejuggler)
#### Post date: [July 1, 2008, 11:53am UTC](https://forum.kirupa.com/t/button-open-close-text-field/264819/5 "2008-07-01T11:53:26Z")

</div>

First set the text object in the library to be exported for actionscript (right click and click on properties).

Then change the code to this:  
button.addEventListener(MouseEvent.CLICK, showText);  
var \_text:myText = new myText();

function showText(event:MouseEvent):void {  
this.addChild(\_text);  
\_text.x = 100;  
\_text.y = 100;  
button.removeEventListener(MouseEvent.CLICK, showText);  
button.addEventListener(MouseEvent.CLICK, hideText);  
}

function hideText(event:MouseEvent):void {  
this.removeChild(\_text);  
button.removeEventListener(MouseEvent.CLICK, hideText);  
button.addEventListener(MouseEvent.CLICK, showText);  
}  
stop();

Should work.

---

<div class="post-metadata">

### Author: ![drakkonblade](https://avatars.discourse-cdn.com/v4/letter/d/46a35a/32.png) [@drakkonblade](https://forum.kirupa.com/u/drakkonblade)
#### Post date: [July 1, 2008, 11:29pm UTC](https://forum.kirupa.com/t/button-open-close-text-field/264819/6 "2008-07-01T23:29:32Z")

</div>

thanks and deeply appreciate your effort and time with the help.

thanks and it works wonderfully :):party:
