# Selected button in menu

**URL:** <https://forum.kirupa.com/t/selected-button-in-menu/249983>\
**Category:** flash\
**Created:** [January 24, 2008, 5:56am UTC](https://forum.kirupa.com/t/selected-button-in-menu/249983 "2008-01-24T05:56:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![deathbydesignnz](https://avatars.discourse-cdn.com/v4/letter/d/977dab/32.png) [@deathbydesignnz](https://forum.kirupa.com/u/deathbydesignnz)\
**Post date:** [January 24, 2008, 5:56am UTC](https://forum.kirupa.com/t/selected-button-in-menu/249983/1 "2008-01-24T05:56:51Z")

</div>

hey, i was wondering if anyone would be keen to convert this to AS3 for me? ive had a go but can only get the rollovers/out working not the selected button function… I tried using event.currentTarget but i dont know how to reset the previous selected button…

Heres the AS2 script:

/\*  
Created by Helen Triolo 2006/05/13 for [flash-creations.com](http://flash-creations.com)  
As described at [http://flash-creations.com/notes/groupofbuttons.php](http://flash-creations.com/notes/groupofbuttons.php)  
\*/

// create an array of all nav buttons in group  
var groupinfo:Array = [birds, dogs, bears, giraffes, mice];

// create constants to define start and stop of grow and shrink sequences  
// (shrink should be exactly the same sequence as grow, in reverse frame order)  
var GROWSTART:Number = 10;  
var GROWSTOP:Number = 19;  
var SHRINKSTART:Number = 20;  
var SHRINKSTOP:Number = 29;

// create a variable to track the currently selected button  
var activebtn:MovieClip;

// doRollOver: start the rollover action or process,  
// unless the button is currently selected  
function doRollOver() {  
if (this != activebtn) {  
// if shrinking, send to corresponding frame in grow  
if (this.\_currentframe \> SHRINKSTART && this.\_currentframe \< SHRINKSTOP) {  
this.gotoAndPlay(GROWSTART + SHRINKSTOP - this.\_currentframe);  
} else {  
this.gotoAndPlay(GROWSTART);  
}  
}  
}

// doRollOut: start the rollout action or process,  
// unless the button is currently selected  
function doRollOut() {  
if (this != activebtn) {  
// if growing, send to corresponding frame in shrink  
if (this.\_currentframe \> GROWSTART && this.\_currentframe \< GROWSTOP) {  
this.gotoAndPlay(SHRINKSTART + GROWSTOP - this.\_currentframe);  
} else {  
this.gotoAndPlay(SHRINKSTART);  
}  
}  
}

// doClick: 1) return previously selected button to normal, 2) show visual  
// indication of selected button, 3) update activebtn  
function doClick() {  
activebtn.gotoAndStop(SHRINKSTOP); // return previously selected to normal

delete this.onEnterFrame; // stop activity on selected mc  
this.gotoAndStop(GROWSTOP); // change appearance of selected mc

activebtn = this; // update pointer to current selection  
}

// assign functions to each event for each button in the group  
function init() {  
for (var mc in groupinfo) {  
groupinfo[mc].onRollOver = doRollOver;  
groupinfo[mc].onRollOut = doRollOut;  
//groupinfo[mc].onRelease = doClick;  
}  
}

init();
