# \[Flash 8\] Making Buttons Remember after they have been clicked

**URL:** https://forum.kirupa.com/t/flash-8-making-buttons-remember-after-they-have-been-clicked/204712
**Category:** Uncategorized
**Created:** [October 22, 2006, 9:52pm UTC](https://forum.kirupa.com/t/flash-8-making-buttons-remember-after-they-have-been-clicked/204712 "2006-10-22T21:52:13Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![The\_Twin](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/the_twin/32/2935_2.png) [@The\_Twin](https://forum.kirupa.com/u/The_Twin)
#### Post date: [October 22, 2006, 9:52pm UTC](https://forum.kirupa.com/t/flash-8-making-buttons-remember-after-they-have-been-clicked/204712/1 "2006-10-22T21:52:13Z")

</div>

Hello!  
I am trying to make my buttons do [this (\<-- Link). What I can’t figure out is how to make the button stay red after the user clicks it and then go back to white when the user click on another button. Here is [URL=“http://www.geocities.com/flash4storage/PhotoGallery.swf”]my file](http://www.geocities.com/flash4storage/week3_lesson2.swf) (\<-- Link) so far. and here is my Code:

```auto

var fade = false;
var depth = 1000;
var buttonNames = new Array("1", "2", "3", "4", "5");

for (var x = 0; x < buttonNames.length; x++) {
    var newButton = this.attachMovie("theButton", "button" + x, depth++);
    newButton._x = 35;
    newButton._y = 35 + ((newButton._height + 17) * x);
    
    newButton.text_mc.dynamic_txt.text = buttonNames[x];
    

newButton.onRollOver = function() { fade = true; }
newButton.onRollOut = function() { fade = false; }

```

Inside the newButton movie clip is this code:

```auto
stop();

var fade = false;

this.onEnterFrame = function() {
    if (fade == true) {
        this.nextFrame();
    } else {
        this.prevFrame();
    }
    
}

this.onRollOver = function() { fade = true; }
this.onRollOut = function() { fade = false; }

```

So if anyone can help me figure out how to make the code remember what button you are on (such as the .swf in the first link) that would be awesome. Thanks!  
-Loren :thumb:

---

<div class="post-metadata">

### Author: ![junkerjorg](https://avatars.discourse-cdn.com/v4/letter/j/9d8465/32.png) [@junkerjorg](https://forum.kirupa.com/u/junkerjorg)
#### Post date: [October 23, 2006, 4:03am UTC](https://forum.kirupa.com/t/flash-8-making-buttons-remember-after-they-have-been-clicked/204712/2 "2006-10-23T04:03:44Z")

</div>

I used this on a site to remember which button was clicked and unclick it when another was clicked. Maybe you can adapt it to what your trying to do.

```auto
var num:MovieClip;

function clicked() {
    this.gotoAndStop(21);
    this.enabled = false;
    num.enabled = true;
    num.gotoAndPlay(11);
    num = this;
}

```

---

<div class="post-metadata">

### Author: ![hal0gical](https://avatars.discourse-cdn.com/v4/letter/h/a587f6/32.png) [@hal0gical](https://forum.kirupa.com/u/hal0gical)
#### Post date: [October 23, 2006, 5:17am UTC](https://forum.kirupa.com/t/flash-8-making-buttons-remember-after-they-have-been-clicked/204712/3 "2006-10-23T05:17:55Z")

</div>

var king = new Object();

// inside a for varaible

temp.onRollOut = function() {  
if ( this.isOn ) {  
return;  
}  
temp.gotoAndStop(1);  
}  
temp.onRelease = function() {  
king.gotoAndStop(1);  
king.isOn = false;  
this.gotoAndStop(2);  
this.isOn = true;  
king = this;  
}

---

<div class="post-metadata">

### Author: ![The\_Twin](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/the_twin/32/2935_2.png) [@The\_Twin](https://forum.kirupa.com/u/The_Twin)
#### Post date: [October 24, 2006, 7:06am UTC](https://forum.kirupa.com/t/flash-8-making-buttons-remember-after-they-have-been-clicked/204712/4 "2006-10-24T07:06:19Z")

</div>

Hey,  
Thanks for the help. I actually figured out using a different method. However I am going to try what you guys suggested. Anyways, here’s the [PhotoGallery](http://www.geocities.com/flash4storage/PhotoGallery.swf) (\<—Link) for anyone who is interested. Thanks again!  
-Loren

(it won’t actually be as large as it is. Geocities just happens to resize flash files)
