How to change the value of a class from a different class

Hi,

I have two classes, class A and class B, where class A contains an input fields and its value can be modified by calling its instance name and giving it a new value


package {
	import flash.display.*;
	import flash.events.*;
	import flash.net.*;
	public class A extends MovieClip {
		public function A() {
			// constructor
			button.addEventListener(MouseEvent.CLICK, changeValue);
		}

		function changeValue(e:MouseEvent):void {
			myText_txt.text='.20';
			trace("size changed");
		}

	}
}

And it works fine, the problems is when I try to change the value of this input field (myText_txt) from class B, I did something like this… and it didn’t work.


package {
	import flash.display.*;
	import flash.events.*;
	import flash.net.*;
	public class B extends MovieClip {
		var a:A;

		public function B() {
			a=new A();
			button.addEventListener(MouseEvent.CLICK, changeValue);
		}

		function changeValue(e:MouseEvent):void {
			a.myText_txt.text='.20';
			trace("size changed");
		}

	}
}

I get the trace statement message but it doesn’t change the value of myText_txt fields.

I tried extending class A in class B but I got an error that says”TypeError: Error #1009: Cannot access a property or method of a null object reference.” Thats why I’m using the composition method but as you can see it is not working.

Any idea what I’m doing wrong? I know it is hard without seeing the actual code from each class.

Oh, both classes are attached to a movieClip in the library.

Thanks