# Button Class referencing/controlling external MC

**URL:** https://forum.kirupa.com/t/button-class-referencing-controlling-external-mc/318896
**Category:** flash
**Created:** [February 2, 2011, 10:25pm UTC](https://forum.kirupa.com/t/button-class-referencing-controlling-external-mc/318896 "2011-02-02T22:25:29Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![simon\_davies](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@simon\_davies](https://forum.kirupa.com/u/simon_davies)
#### Post date: [February 2, 2011, 10:25pm UTC](https://forum.kirupa.com/t/button-class-referencing-controlling-external-mc/318896/1 "2011-02-02T22:25:29Z")

</div>

I have this following class attached to some of my buttons to simply control the roll over and out states, as well as the click event.

But i want to use the same class on my buttons but would like to control a movieclip outside of the button somewhere else on the stage etc.

put simply: Clicking my button ‘moveLeft’ will move a movieclip left let say:

My code is as follows :

```auto
package com.sd{
	import flash.display.*;
	import flash.events.*;
 
	public class buttonEffect extends MovieClip {
				
			//-- constructor --//
		public function buttonEffect():void
		{
			stop();
			this.buttonMode = true;
			this.addEventListener(MouseEvent.CLICK, BtnClick);
			this.addEventListener(MouseEvent.MOUSE_OVER, BtnOver);
			this.addEventListener(MouseEvent.MOUSE_OUT, BtnOut);
		}
			
			//-- my methods --//
		public function BtnClick(e:MouseEvent):void
		{
			// when the button is clicked I need to control a movie clip outside of this button
			//how woudl I reference a movieclip outside of this class
			
			
		}
		
		public function BtnOver(e:MouseEvent):void
		{
			this.gotoAndStop(2);
		}
		
		public function BtnOut(e:MouseEvent):void
		{
			this.gotoAndStop(1);
		}
	
	}
}

```

Manyy Thanks  
Si
