# Deactivate a button...or mc

**URL:** https://forum.kirupa.com/t/deactivate-a-button-or-mc/185070
**Category:** flash
**Created:** [April 10, 2006, 6:50pm UTC](https://forum.kirupa.com/t/deactivate-a-button-or-mc/185070 "2006-04-10T18:50:57Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![MJ\_Creations](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mj_creations/32/2242_2.png) [@MJ\_Creations](https://forum.kirupa.com/u/MJ_Creations)
#### Post date: [April 10, 2006, 6:50pm UTC](https://forum.kirupa.com/t/deactivate-a-button-or-mc/185070/1 "2006-04-10T18:50:57Z")

</div>

Ok, I can’t figure this out. I’m pretty new to flash…  
Here’s the situation-  
I’ve got a webpage- all the buttons (mc’s) are located on the main timeline, then on the top left at (0,0) i have an empty movie clip with the instance name “content”. This is where I am loading the external .swf files for the other pages on the site.  
So, as an example, this is what i am using for the button.

```auto
 
on(release){
_parent.content.loadMovie("page1.swf");
}

```

Now when I click on that button, it loads “page1.swf” into the content movie clip. But if I click the same button again- “page1.swf” dissapears and comes back. I understand that logic… But I can’t understand how to make that button not do anything when “page1.swf” is already loaded into the content mc. I’ve searched everywhere, and I used help in flash, but I cant find anything…

BTW I’m using Flash 8- if that changes an answer at all…

Please help!  
Thanks

Matt

---

<div class="post-metadata">

### Author: ![nvg](https://avatars.discourse-cdn.com/v4/letter/n/e9bcb4/32.png) [@nvg](https://forum.kirupa.com/u/nvg)
#### Post date: [April 10, 2006, 7:23pm UTC](https://forum.kirupa.com/t/deactivate-a-button-or-mc/185070/2 "2006-04-10T19:23:52Z")

</div>

Hi m8,

I’m sort of new to flash as well but I managed to make something work by putting this in with your button code,

```auto

on(release){
 if (_root.section != "page1.swf") 
 {  
  _root.section = "page1.swf";
  _root.content.loadMovie("page1.swf");
 }
}

```

I pretty much lifted this from a tutorial on this site by Claudio so can’t take credit but hope this helps, here’s the link to the tutorial as well. :kir:

[http://www.kirupa.com/developer/mx/preloader\_transition.htm](http://www.kirupa.com/developer/mx/preloader_transition.htm)

I replaced \_parent with \_root for my test but am hoping you can change that without it not working.

Hope this works for you. 🙂

---

<div class="post-metadata">

### Author: ![kBisk](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@kBisk](https://forum.kirupa.com/u/kBisk)
#### Post date: [April 10, 2006, 7:42pm UTC](https://forum.kirupa.com/t/deactivate-a-button-or-mc/185070/3 "2006-04-10T19:42:49Z")

</div>

Give the button an instance name like “mybutton” then you can disable it using:[AS]mybutton.enabled=false;[/AS]

---

<div class="post-metadata">

### Author: ![MJ\_Creations](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mj_creations/32/2242_2.png) [@MJ\_Creations](https://forum.kirupa.com/u/MJ_Creations)
#### Post date: [April 10, 2006, 10:02pm UTC](https://forum.kirupa.com/t/deactivate-a-button-or-mc/185070/4 "2006-04-10T22:02:43Z")

</div>

> [@Carbon21](#):
>
> Give the button an instance name like “mybutton” then you can disable it using:ActionScript Code:  
> [FONT=Courier New][LEFT]mybutton.[COLOR=#0000ff]enabled[/COLOR]=[COLOR=#000000] **false** [/COLOR];  
> [/LEFT]  
> [/FONT]

yea i got that part… the part i dont get is i only want it disabled when the page1 is loaded…

---

<div class="post-metadata">

### Author: ![kBisk](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@kBisk](https://forum.kirupa.com/u/kBisk)
#### Post date: [April 11, 2006, 12:01pm UTC](https://forum.kirupa.com/t/deactivate-a-button-or-mc/185070/5 "2006-04-11T12:01:51Z")

</div>

While you could add:[AS]mybutton1.onRelease=function(){  
resetall();  
this.enabled=false;  
}  
//replace numberOfButtons below with correct number  
function resetall(){  
for(var i=1; i\<=numberOfButtons; i++){  
eval(“mybutton”+i).enabled=true;  
}  
}  
//now all button instances must be mybutton1, mybutton2, etc.[/AS]

---

<div class="post-metadata">

### Author: ![boua5828](https://avatars.discourse-cdn.com/v4/letter/b/eb8c5e/32.png) [@boua5828](https://forum.kirupa.com/u/boua5828)
#### Post date: [April 17, 2006, 8:27pm UTC](https://forum.kirupa.com/t/deactivate-a-button-or-mc/185070/6 "2006-04-17T20:27:34Z")

</div>

This code works great. How would I adapt it so that when another button (MC) is clicked, the previous one is reactivated?

For example, I am using movie clips for my buttons which have frame labels for each state; “off”, “over”, “out” and “active”. Using the provided code, the playhead of my MCs stay on the “active” label to indicate that the current page corresponds with the selection they have made. I need the unclicked MCs to all be set to the “off” label when another one is clicked.

Thanks in advance.

---

<div class="post-metadata">

### Author: ![kBisk](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@kBisk](https://forum.kirupa.com/u/kBisk)
#### Post date: [April 17, 2006, 10:45pm UTC](https://forum.kirupa.com/t/deactivate-a-button-or-mc/185070/7 "2006-04-17T22:45:44Z")

</div>

Add the following to **resetall()** under **for** :

**eval(“mybutton”+i).gotoAndStop(‘off’);**

so it would look like:

[AS]function resetall(){  
for(var i=1; i\<=numberOfButtons; i++){  
eval(“mybutton”+i).enabled=true;  
eval(“mybutton”+i).gotoAndStop(‘off’);  
}  
}  
[/AS]

---

<div class="post-metadata">

### Author: ![boua5828](https://avatars.discourse-cdn.com/v4/letter/b/eb8c5e/32.png) [@boua5828](https://forum.kirupa.com/u/boua5828)
#### Post date: [April 18, 2006, 12:23pm UTC](https://forum.kirupa.com/t/deactivate-a-button-or-mc/185070/8 "2006-04-18T12:23:51Z")

</div>

Thanks Carbon. I’ve added the code and it’s not quite achieving the desired effect.

[HERE](http://www.images123.com/prototype/ImagesPhotography_prototype2_041706.swf) is a link to the skeletal build of the site. What I’m hoping to achieve is to have the active link stay in the “up” position. The provided code acts on all of the links - including the one selected.

If it will help, I’ll post my code. 🍺

---

<div class="post-metadata">

### Author: ![kBisk](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@kBisk](https://forum.kirupa.com/u/kBisk)
#### Post date: [April 18, 2006, 2:06pm UTC](https://forum.kirupa.com/t/deactivate-a-button-or-mc/185070/9 "2006-04-18T14:06:31Z")

</div>

Oh you need the current button to stay on as well then?

In the button onRelease function add **this.gotoAndStop(‘active’);** under the **resetall()** line.

So it’ll be:  
[AS]mybutton1.onRelease=function(){  
resetall();  
this.gotoAndStop(‘active’);  
this.enabled=false;  
}[/AS]Hope this solves it.

---

<div class="post-metadata">

### Author: ![boua5828](https://avatars.discourse-cdn.com/v4/letter/b/eb8c5e/32.png) [@boua5828](https://forum.kirupa.com/u/boua5828)
#### Post date: [April 18, 2006, 2:55pm UTC](https://forum.kirupa.com/t/deactivate-a-button-or-mc/185070/10 "2006-04-18T14:55:53Z")

</div>

Excellent! I had that in my code already - but in the wrong order. :crazy: Thanks for helping to clear this up for me.

---

<div class="post-metadata">

### Author: ![kBisk](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@kBisk](https://forum.kirupa.com/u/kBisk)
#### Post date: [April 18, 2006, 2:56pm UTC](https://forum.kirupa.com/t/deactivate-a-button-or-mc/185070/11 "2006-04-18T14:56:27Z")

</div>

No problem.
