# How to use onChange in a class?

**URL:** <https://forum.kirupa.com/t/how-to-use-onchange-in-a-class/86422>\
**Category:** flash\
**Created:** [April 12, 2005, 9:33pm UTC](https://forum.kirupa.com/t/how-to-use-onchange-in-a-class/86422 "2005-04-12T21:33:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ownersbox](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ownersbox/32/1218_2.png) [@ownersbox](https://forum.kirupa.com/u/ownersbox)\
**Post date:** [April 12, 2005, 9:33pm UTC](https://forum.kirupa.com/t/how-to-use-onchange-in-a-class/86422/1 "2005-04-12T21:33:31Z")

</div>

I want to add a listener to two textfields in an mc, not sure how to change the function to work properly in a class. The mc has a class associated to it. I have included the code below.

Thanks for any help

The error I get for each function

```
 [left]  

```

```auto
 
Line 23: '(' expected
		 function description.onChanged(textfield_txt:TextField) {
Line 20: The same member name may not be repeated more than once.
		 function titlename.onChanged(textfield_txt:TextField) {[/left]
   

```

```auto
  [left]class Note extends MovieClip {
	var x:Number;
	var y:Number;
	public var titlename:TextField;
	public var description:TextField;
	public var txtListener:Object = new Object();
	   
	public function Note() {
		titlename.value = "Enter Your Title";
		description.value = "Enter Your Description";
		trace("+++++++");
		titlename.addListener(txtListener);
		description.addListener(txtListener);
		}
	function setInfo() {
	}
	function getInfo() {
	}
	
	function titlename.onChanged(textfield_txt:TextField) {
		trace(textfield_txt._name+" changed");
	};
	function description.onChanged(textfield_txt:TextField) {
		trace(textfield_txt._name+" changed");
	};
	function txtListener.onChanged(textfield_txt:TextField) {
		trace(textfield_txt._name+" changed and notified myListener");
	};
}

```

[/left]
