Dynamic button question | assigning actions

Hi there.

I have a little problem… hopefully somebody can help!

below I have a script; what it does is is read a numeric variable (projects) from “text.txt” and dynamically attaches a relevant number of movie clips in a row. Each one of these movie clips serves as a simple two frame “button”; frame one is the unselected state, and frame two is the selected state…

// load external data

loadData = new LoadVars();
loadData.onLoad = function() {

// for loop - process external variable
for (i=1; i<=loadData.projects; i++) {

// create buttons
var myButton:MovieClip = _root.galleryList.galleryFashion.attachMovie("attachButton", i, 100+i);

// name button (dynamic text field)
myButton.textboxname.text = "button " + j;

// position buttons
myButton._x = 0;
myButton._y = i*20;

// assign actions to button
projectButton.onRelease = function() {

	this.gotAndStop(2); // highlight clicked button - goto selected state
  }  

}
}
loadData.load(“text.txt”);

anyway, this script works just fine, as is. the variable reads in perfectly, the movie clips attach etc. my problem is this:

I want the button that I click to go to its active state. this is no problem as all I have to do is add an onRelease/gotoAndStop() command which is attributed to each button as it is created, as above. my problem is that, say I had a bunch of dynamically generated buttons, when I click one of these buttons I don’t know how to tell the other buttons to revert to their inactive states i.e: return to their first frames.

I realise that this is probably not very complicated, but I’m feeling very feeble minded today.

so in short, help! :slight_smile:

muchas gracias, plug.