# Array buttons and other buttons

**URL:** https://forum.kirupa.com/t/array-buttons-and-other-buttons/235473
**Category:** Uncategorized
**Created:** [August 11, 2007, 3:44pm UTC](https://forum.kirupa.com/t/array-buttons-and-other-buttons/235473 "2007-08-11T15:44:26Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jwkep](https://avatars.discourse-cdn.com/v4/letter/j/848f3c/32.png) [@jwkep](https://forum.kirupa.com/u/jwkep)
#### Post date: [August 11, 2007, 3:44pm UTC](https://forum.kirupa.com/t/array-buttons-and-other-buttons/235473/1 "2007-08-11T15:44:26Z")

</div>

senerio:

var activebtn:MovieClip;

function releaseAction(){  
if(!=activebtn){  
//myaction (eg. change button color, change all others to opposite color);  
this = activebtn;  
}  
}

array=[button1, button2, button3, button3]

for(var mc in array){  
this[array[mc].onRelease = releaseAction;  
}

the above part works fine. currently my whole site is created with button arrays with each page being loaded into a master page. So the master page has the main navigation and then the child pages eachh contain their own navigation such as item1, item2, etc. One of the pages needs to communicate with the other page in the sense that when I click on a button it needs to go to the other section and go to a specific item. So when you go to the other page the nav highlight needs to highlight the correct page and highlight the correct item.

this is the link:  
[http://jae-que.com/DROP/NIKE\_COMM/T0...C\_site\_01.html](http://jae-que.com/DROP/NIKE_COMM/T0...C_site_01.html)

so when I am in “our clients” I can click on “see case study” and go to the case study page and highlight the case study menu item and highlight the correct item within that page. I can do it the hard way by specifying everything manually, but somehow it seems that with an array I could target the button with another button and trigger the appropriate events. I need to do this more than once so the more streamlined the better.

here is some sample code that works with a button manually placed on the stage triggering one of the buttons that is created dynamically:

//Create movieclip array  
var CircArray:Array = new Array();  
//Create and push movieclips into array  
for (i=0; i\<5; i+1) {  
this.attachMovie(“CircTest”, “CircTest”+i, i++);  
this[“CircTest”+i].\_y = (Stage.height/2)-(this[“CircTest”+i].\_height/2);  
this[“CircTest”+i].\_x = (this[“CircTest”+i].\_width+30)_i;  
var pushed:Number = CircArray.push(“CircTest”+i);  
}  
//Change all clips to 10% alpha  
for (i=0; i\<CircArray.length; i++) {  
this[CircArray_].\_alpha = 10;  
}  
//set old selection variable  
var activebtn:MovieClip;  
//on click function  
function doClick() {  
if (this != activebtn) {  
//change old selection back  
activebtn.\_alpha = 10;  
activebtn.\_alpha = 10;  
colorA = new Color(activebtn);  
colorA.setRGB(0x000000);  
//change new selection  
this.useHandCursor = false;  
this.\_alpha = 100;  
colorB = new Color(this);  
colorB.setRGB(0xFF0000);  
activebtn = this;  
}  
}  
//  
function thisColor() {  
for (var mc in CircArray) {  
this[CircArray[mc]].onRelease = doClick;  
}  
}  
thisColor();  
//  
//this is the part that does not work (this button is manually place and not part of the arrray  
MainChange.onRelease = CircTest1=function () {  
trace(this);  
CircTest1 = doClick;  
};
