# Adding a listener

**URL:** <https://forum.kirupa.com/t/adding-a-listener/9839>\
**Category:** Uncategorized\
**Created:** [December 19, 2002, 2:29pm UTC](https://forum.kirupa.com/t/adding-a-listener/9839 "2002-12-19T14:29:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![j0se](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/j0se/32/44_2.png) [@j0se](https://forum.kirupa.com/u/j0se)\
**Post date:** [December 19, 2002, 2:29pm UTC](https://forum.kirupa.com/t/adding-a-listener/9839/1 "2002-12-19T14:29:16Z")

</div>

hello!  
i have a dynamic textbox (txtBox) in a mc, and two buttons to scroll up and down (scrollUp & Down)

here’s what i want to do:

the scroll buttons should remain invisible until the textbox is updated

i’m doing this with actionscript so i believe i cannot use the textboxe’s onChanged method, but have to set up a listener

ok, here’s what i have on teh first ferame of the mc:

// set buttons to invisible  
scrollUp.\_visible = false;  
scrollDown.\_visible = false;

// define listener  
checkStatus = {};  
checkStatus.onChanged = function(){  
scrollUp.\_visible = true;  
scrollDown.\_visible = true;  
}

txtBox.addListener(checkStatus);

hmm, am i anywhere near the goal?  
:-\

---

<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:** [December 19, 2002, 2:38pm UTC](https://forum.kirupa.com/t/adding-a-listener/9839/2 "2002-12-19T14:38:55Z")

</div>

Wel, it’s working, no?

---

<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:** [December 19, 2002, 2:40pm UTC](https://forum.kirupa.com/t/adding-a-listener/9839/3 "2002-12-19T14:40:13Z")

</div>

This should work, unless your using a dynamic text field, it won’t work though, only on Input TextFields.

scrollUp.\_visible = false;  
scrollDown.\_visible = false;

myField.onChanged = function(){  
scrollUp.\_visible = true;  
scrollDown.\_visible = true;  
}

---

<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:** [December 19, 2002, 3:27pm UTC](https://forum.kirupa.com/t/adding-a-listener/9839/4 "2002-12-19T15:27:04Z")

</div>

ah, no it’s not working ☹

and yes, i’m using a dynamic textbox

i just thought: i could declare a variable to hold all the text that i’m loading, and if that variable is equal to something, THEN i could load the textbox and set the scroll buttons to visible

unless there’s a way of dong it without creating a new var

cheers so far (-:

---

<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:** [December 19, 2002, 3:38pm UTC](https://forum.kirupa.com/t/adding-a-listener/9839/5 "2002-12-19T15:38:18Z")

</div>

Try anything other than onChanged. :-\

---

<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:** [December 19, 2002, 4:29pm UTC](https://forum.kirupa.com/t/adding-a-listener/9839/6 "2002-12-19T16:29:29Z")

</div>

i now turn the scroll butons to visible within the function that loads the file (if it loads the file ok) - i don’t know why i didn;t think of that - it’s prety logical

so i got:  
// function  
loadText.onLoad = function(success) {  
if (success){  
// load text into text box  
\_root.text\_mc.txtBox.text = this.fileText;  
// and turn the scroll buttons to visible  
\_root.text\_mc.scrollUp.\_visible=true;  
\_root.text\_mc.scrollDown.\_visible=true;  
…

sorry about that :A+: (more thought next time)

cheers

---

<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:** [December 19, 2002, 5:13pm UTC](https://forum.kirupa.com/t/adding-a-listener/9839/7 "2002-12-19T17:13:05Z")

</div>

Glad you got it working. 🙂
