# \[mx\] make mcs act like true buttons - prototype

**URL:** <https://forum.kirupa.com/t/mx-make-mcs-act-like-true-buttons-prototype/29609>\
**Category:** flash\
**Created:** [August 28, 2003, 4:43pm UTC](https://forum.kirupa.com/t/mx-make-mcs-act-like-true-buttons-prototype/29609 "2003-08-28T16:43:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![kdzines](https://avatars.discourse-cdn.com/v4/letter/k/7ea924/32.png) [@kdzines](https://forum.kirupa.com/u/kdzines)\
**Post date:** [August 28, 2003, 4:43pm UTC](https://forum.kirupa.com/t/mx-make-mcs-act-like-true-buttons-prototype/29609/1 "2003-08-28T16:43:20Z")

</div>

hey everyone,

i have a site with all mc buttons, and the site is spread over a few scenes(arghh - i know, but this what it is)!

I have used a great protoype that lost wrote for me a while back:

[http://www.kirupaforum.com/forums/showthread.php?s=&threadid=21939](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=21939)

so with his prototype, when you click an mc, it makes that on “highlight” and makes all the other ones in the array “lowlight”.

```php

//array to store button instance names
var navTopArray = ["company", "commissions", "projects", "press", "contact", "credits"];
//create the prototype call changeColors
MovieClip.prototype.navTopColors = function() {
	//create for loop to go through the buttonArray list
	for (var i = 0; i<navTopArray.length; i++) {
		//create color object that targets each clip in the array
		var myColor = new Color(this._parent[navTopArray*]);
		//if the instance name in the current position in the array is not equal to this clips name
		if (navTopArray* != this._name) {
			//set the RGB value to 0x000000 (light)
			myColor.setRGB(0xffffff);
		} else {
			//else if it is the same as ths clips name
			//set the RGB to 0xFF0000 (dark)
			myColor.setRGB(0x7f7f7f);
		}
	}
};

```

But for this site i have a big problem. When you enter each scene, the relevant button is highlighted - which i did by putting this code :

```php

_root.nav.projectssubnav.projectssub4.navSubColors();

```

and when the user clicks another button, they go to another scene where another button is lit up.

But now i want to set it so that on rollover, each of the other buttons lights up in a third colour, and returns to its lowlight on rollout. BUT i want the button for the current scene to always remain highlighted.

Now i can see this being a problem with the protoype i have, so does anyone know i good way round this?

I am used to html where you have up, over, down states and that is what i am trying to recreate.

I really hope there is a good way to do this using a prototype, otherwise its gonna take forever as there are 80+ buttons.

Please help in whatever way you can,

thanks

kd

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 29, 2003, 12:47pm UTC](https://forum.kirupa.com/t/mx-make-mcs-act-like-true-buttons-prototype/29609/2 "2003-08-29T12:47:55Z")

</div>

I can , quickly, think of a patch like:  
[AS]  
//array to store button instance names  
var navTopArray = [“company”, “commissions”, “projects”, “press”, “contact”, “credits”];  
//create the prototype call changeColors  
MovieClip.prototype.navTopColors = function( **aSelection** ) {  
//create for loop to go through the buttonArray list  
for (var i = 0; i\<navTopArray.length; i++) {  
//create color object that targets each clip in the array  
var myColor = new Color(this.\_parent[navTopArray\*]);  
//if the instance name in the current position in the array is not equal to this clips name  
if (navTopArray\* != this.\_name) {  
//set the RGB value to 0x000000 (light)  
\*\* if(navTopArray\* != aSelection){  
myColor.setRGB(0xffffff);  
} else {  
myColor.setRGB(0x6666ff);  
}\*\*  
} else {  
//else if it is the same as ths clips name  
//set the RGB to 0xFF0000 (dark)  
myColor.setRGB(0x7f7f7f);  
}  
}  
};  
[/AS]  
if you don’t want the selected one to have a rollOver do the same to the the other colour in the if statement.

Now when you call the navTopColors function pass the selected section i.e.navTopColors(“company”);

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 29, 2003, 1:16pm UTC](https://forum.kirupa.com/t/mx-make-mcs-act-like-true-buttons-prototype/29609/3 "2003-08-29T13:16:30Z")

</div>

hey another londoner!

Thanks for the help, but i’m still a bit confused. Could you write the actions for 1 of the buttons to help me understand how you call the function for the rollover colour, and how to sort out the button not chanigng colour?

Any idea where i can read up on functions, i really don’t get what happens to the things (inside the bracket), and how you pass the function and why?

any help you would be great

thanks mate

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 29, 2003, 1:22pm UTC](https://forum.kirupa.com/t/mx-make-mcs-act-like-true-buttons-prototype/29609/4 "2003-08-29T13:22:52Z")

</div>

if u give me a bit of time i’ll try to put together a Fla file

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 29, 2003, 1:31pm UTC](https://forum.kirupa.com/t/mx-make-mcs-act-like-true-buttons-prototype/29609/5 "2003-08-29T13:31:08Z")

</div>

wicked man!

thanks a lot!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 29, 2003, 2:17pm UTC](https://forum.kirupa.com/t/mx-make-mcs-act-like-true-buttons-prototype/29609/6 "2003-08-29T14:17:35Z")

</div>

Hi,  
There you go.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 29, 2003, 2:25pm UTC](https://forum.kirupa.com/t/mx-make-mcs-act-like-true-buttons-prototype/29609/7 "2003-08-29T14:25:51Z")

</div>

arghh!

I’m well confused! I’m gonna try and figure out how to use your code in my project.

Thanks so much for all the help, i hope i can get this to work.

cheers,

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 29, 2003, 6:26pm UTC](https://forum.kirupa.com/t/mx-make-mcs-act-like-true-buttons-prototype/29609/8 "2003-08-29T18:26:19Z")

</div>

hi again eki,

I’ve been going through your fla, and am seriously confused. I’m really sorry to bother you, but can you explain the init function?

i get the button functions (kind of). In the site i’m doing, i have 12-15 scenes and in each scene i have some nav buttons.

i always call the functions like this:

```php

_root.company.onRollOver = function(){
this.navTopColors();
}
_root.company.onRollOut = function(){
this.navButtRollOut();
}

i get really confused when buttons are put in arrays etc for the button actions.
Cards on the table, i am rubbish with for actions, referencing arrays etc. It's something that i'm trying to learn, but i have to complete this site by Monday and i'm freaking out!

So if you can help in any way more, i would be soooo grateful!!!

thanks again

kd
```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 29, 2003, 8:16pm UTC](https://forum.kirupa.com/t/mx-make-mcs-act-like-true-buttons-prototype/29609/9 "2003-08-29T20:16:15Z")

</div>

right,

i finally figured out how to use the code to do exactly what i wanted - WOOHOO!

I still don’t really get it all, but if it works then i’m relieved!

Hey what do you do in london, r u in web design? Could have some work for you in the future.

Cheers for all the help,

kd

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 29, 2003, 11:16pm UTC](https://forum.kirupa.com/t/mx-make-mcs-act-like-true-buttons-prototype/29609/10 "2003-08-29T23:16:31Z")

</div>

really sorry to bother you again, but i’m so close to getting this to work.

In your example, the buttons are on the stage, i just want to know how to change the code to target the buttons if they are all inside 1 mc called “nav”. Specifically i need to know how to have one of the buttons initially highlighted:

this.currentselection = “company”;

i’m so stuck on the pathing you have used.

please help me man!

Any explanation of :

butt.root = this.

i just can’t understand it!!

thanks

kd
