# Disable on click

**URL:** <https://forum.kirupa.com/t/disable-on-click/13579>\
**Category:** Uncategorized\
**Created:** [February 14, 2003, 10:04pm UTC](https://forum.kirupa.com/t/disable-on-click/13579 "2003-02-14T22:04:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![elietabet](https://avatars.discourse-cdn.com/v4/letter/e/a9a28c/32.png) [@elietabet](https://forum.kirupa.com/u/elietabet)\
**Post date:** [February 14, 2003, 10:04pm UTC](https://forum.kirupa.com/t/disable-on-click/13579/1 "2003-02-14T22:04:47Z")

</div>

my main page has 5 buttons. when it loads, it has nothing. the user should should from the buttons where he wants to go: about, pictures, graphics, webdesign,contact.

i want to disable each button in its own page. for example, when clicked on “about”, the about SWF loads but i want the “about” button to be disabled in his page.

same for the rest. i have some mouseover captions also.

i tried the code posted by electrongeek but it didnt work at all.

## this is the code on each button:

## on (release) { \_root.contents.loadMovie(“about.swf”); //or pictures.swf, … etc } on (rollOver) { \_root.x = 1; \_root.caption.words = “About me”; } on (rollOut) { \_root.x = 0; \_root.caption.words = " "; }

---

<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:** [February 14, 2003, 10:24pm UTC](https://forum.kirupa.com/t/disable-on-click/13579/2 "2003-02-14T22:24:43Z")

</div>

```php
//all button code
Button_Names = ['about', 'portfolio', 'extras', 'audio', 'client', 'email', 'phone', 'privacy', 'credits', 'as'];
for (i=0; i<=Button_Names.length-1; i++) {
        item = Button_Names*;
        this[item+"_btn"].mov = item;s
        this[item+"_btn"].onRelease = function() {
                //trace('release: load movie: '+this.mov+'.swf');
                loadMovieNum(this.mov+".swf", 2);
                this.gotoAndStop("_disabled");
                this.enabled = 0;
                Enable_Buttons(this.mov);
        };
        this[item+"_btn"].onRollOver = function() {
                //trace("over: " + this.mov);
                this[item+"_btn"].gotoAndPlay("_over");
        };
        this[item+"_btn"].onRollOut = function() {
                //trace(this.mov+ " is now >> UP");
                this[item+"_btn"].gotoAndPlay("_up");
        };
        this[item+"_btn"].onPress = function() {
                //trace("press: " + this.mov);
                this[item+"_btn"].gotoAndPlay("_down");
        };
}
function Enable_Buttons(selected) {
        for (i=0; i<=Button_Names.length-1; i++) {
                if (Button_Names* != selected) {
                        this[Button_Names*+"_btn"].gotoAndStop("_up");
                        this[Button_Names*+"_btn"].enabled=1;
                }
        }
}
Button.prototype.useHandCursor = false
//end button code

```

this code loads a swf for each content area and disables the selected button and then enables all other buttons, just change the button names. this works very well

---

<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:** [February 15, 2003, 12:20am UTC](https://forum.kirupa.com/t/disable-on-click/13579/3 "2003-02-15T00:20:43Z")

</div>

it didnt do anything.  
should i add it to my previous code ?? or what ??

---

<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:** [February 15, 2003, 12:54am UTC](https://forum.kirupa.com/t/disable-on-click/13579/4 "2003-02-15T00:54:47Z")

</div>

You should use Button.enabled for this, and set it to false when you press a button. But if you want it to work, you’ll have to use dynamic even handlers like Subquark did (in order to be able to do **this**.enabled=0;

pom 🙂

---

<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:** [February 15, 2003, 12:56am UTC](https://forum.kirupa.com/t/disable-on-click/13579/5 "2003-02-15T00:56:19Z")

</div>

Basically

```auto
yourButton.onRelease=function() {
  _root.contents.loadMovie("about.swf"); //or pictures.swf, ... etc
  this.enabled=0;
}

```

You might also need to reactivate the other buttons at that point.

---

<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:** [February 15, 2003, 12:59am UTC](https://forum.kirupa.com/t/disable-on-click/13579/6 "2003-02-15T00:59:11Z")

</div>

got it man, thx

---

<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:** [February 15, 2003, 1:58pm UTC](https://forum.kirupa.com/t/disable-on-click/13579/7 "2003-02-15T13:58:19Z")

</div>

hi elietabet, wish i could take the credit for the code i posted, but i am nowhere near that good. it was developed with the BIG help of certain gracious members of this forum. for a better explanation, you can go to my site and click the “subquark actionscript” button in the lower left hand corner. i put most of the code there and a screenshot of my basic button (an mc) structure - good luck

i hope to one day have a hundredth of the actionscript skill of ilyaslamasse (really, no bs) 🙂
