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

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 (<-- Link) so far. and here is my Code:


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:

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:

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.

var num:MovieClip;

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

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;
}

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 (<—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)