Creating buttons in AS3

I’ve done quite a few projects in Flash but I tend to use it solidly for about three weeks and then I won’t use it again until another project needs it so although I understand Action Script I never quite remember how to write it so I rely heavily on a bunch of examples that I’ve gathered over the years but these are all written in Action Script 2.

I’ve put off using AS3 for this very reason but the longer I leave it this worse this is going to get so I’m determined this time to use AS3 even though its taking me ages.

Anyway my problem, this is just an example but once I have the solution I will be able to use the code on my project. I have an FLA setup with some animated movie clips as buttons, now with some help I had them working in AS2 so that they would stay down until the next one was clicked just like a typical nav bar.

I have tried to write to translate the code into AS3 but I can only get some far, would one of you guys be kind enough to help me out with this. This is my code


var activeMenu = b1_mc;

b1_mc.addEventListener(MouseEvent.MOUSE_OVER, over);
b1_mc.addEventListener(MouseEvent.MOUSE_OUT, out);
b1_mc.addEventListener(MouseEvent.CLICK, clicked)

b2_mc.addEventListener(MouseEvent.MOUSE_OVER, over);
b2_mc.addEventListener(MouseEvent.MOUSE_OUT, out);
b2_mc.addEventListener(MouseEvent.CLICK, clicked)

b3_mc.addEventListener(MouseEvent.MOUSE_OVER, over);
b3_mc.addEventListener(MouseEvent.MOUSE_OUT, out);
b3_mc.addEventListener(MouseEvent.CLICK, clicked)

b4_mc.addEventListener(MouseEvent.MOUSE_OVER, over);
b4_mc.addEventListener(MouseEvent.MOUSE_OUT, out);
b4_mc.addEventListener(MouseEvent.CLICK, clicked)

function over(event:MouseEvent):void
{
	   if(_root.activeMenu == undefined || this._name != _root.activeMenu._name) {
      this.gotoAndPlay(2);
   }
}

function out(event:MouseEvent):void
{
	   if(_root.activeMenu == undefined || this._name != _root.activeMenu._name) {
      this.gotoAndPlay(7);
   }
}

function clicked(event:MouseEvent):void
{
	   if(_root.activeMenu != undefined) {
      _root.activeMenu.gotoAndPlay(7);
   }
   // make menu active
   this.gotoAndStop(20);
   // save new menu item
   _root.activeMenu = this;
}

I have even noticed that this.gotoAndPlay(2) doesn't even seem to work, do I have to write this differently in AS3?