# Access a Class function with another

**URL:** <https://forum.kirupa.com/t/access-a-class-function-with-another/322641>\
**Category:** Uncategorized\
**Created:** [May 28, 2011, 12:03am UTC](https://forum.kirupa.com/t/access-a-class-function-with-another/322641 "2011-05-28T00:03:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![evolutionxbox](https://avatars.discourse-cdn.com/v4/letter/e/ec9cab/32.png) [@evolutionxbox](https://forum.kirupa.com/u/evolutionxbox)\
**Post date:** [May 28, 2011, 12:03am UTC](https://forum.kirupa.com/t/access-a-class-function-with-another/322641/1 "2011-05-28T00:03:49Z")

</div>

Current stage:  
 ![](http://forum.kirupa.com/uploads/kirupa/6546/c9680043e32365d9.jpg)

Class 1 - box on right:

```auto
package 
{
	import flash.display.*;
	import flash.events.*;

	public class box extends MovieClip
	{
		public function box()
		{
		}

		public function moveBoxTo(boxX:int, boxY:int):void
		{
			this.x = boxX;
			this.y = boxY;
		}

	}

}

```

Class 2 - box on left:

```auto
package 
{
	import flash.display.*;
	import flash.events.*;

	public class button extends MovieClip
	{

		private var buttonState:Boolean;

		public function button()
		{
			buttonState = false;
			this.addEventListener(MouseEvent.CLICK, clicked);
		}

		private function clicked(e:Event):void
		{
			if (buttonState === false)
			{
				//this.parent.boxMC.moveBoxTo(0,0);
				buttonState = true;
			}
			else
			{
				//this.parent.boxMC.moveBoxTo(0,0);
				buttonState = false;
			}
		}
	}
}

```

Box on left is a button which when pressed moves button on right. Except it doesn’t as I can’t access a class method from within another.

Solution any one?
