I was looking over this code for building buttons with as, but how do you asign an action to each of them. Like if I wanted to make one button load a movie.
i = 0;
count = 10;
// these vars are for the color of things…
oCBG = 0x666666;// old color (what your bg is now)
ncBG = 0x999999;// new color (what it will be on rollover)
oCTx = 0x333333;// old color of text
nCTx = 0x006699;// the new color of your text
onEnterFrame = function () {
if (i<count) {
btn = _root.attachMovie(“button”, “button”+i, i);
btn._x = 50;
btn._y = (20*i)+50;
btn.onRollOver = function() {
cObj = new Color(this.bg);
cObj.setRGB(ncBG);
format = new TextFormat();
format.color = nCTx;
this.btnText.setTextFormat(format);
};btn.onRollOut = function() {
cObj = new Color(this.bg);
cObj.setRGB(oCBG);
format = new TextFormat();
format.color = oCTx;
this.btnText.setTextFormat(format);
};
btn.btnText.text += " "+i;i++;
}
};
stop();
count = 10;
// these vars are for the color of things...
oCBG = 0x666666;
// old color (what your bg is now)
ncBG = 0x999999;
// new color (what it will be on rollover)
oCTx = 0x333333;
// old color of text
nCTx = 0x006699;
// the new color of your text
for (i=0; i<count; i++) {
btn = _root.attachMovie("button", "button"+i, i);
btn.n = i;
btn._x = 50;
btn._y = (20*i)+50;
btn.onRollOver = function() {
cObj = new Color(this.bg);
cObj.setRGB(ncBG);
format = new TextFormat();
format.color = nCTx;
this.btnText.setTextFormat(format);
};
btn.onRollOut = function() {
cObj = new Color(this.bg);
cObj.setRGB(oCBG);
format = new TextFormat();
format.color = oCTx;
this.btnText.setTextFormat(format);
};
btn.onPress = function() {
//change to the color you want
cObj = new Color(this.bg);
cObj.setRGB(oCBG);
format = new TextFormat();
format.color = oCTx;
this.btnText.setTextFormat(format);
target.loadMovie("url/movie"+this.n+".swf");
//or and add array with the movienames
target.loadMovie("url/"+movieArray[this.n]);
};
btn.btnText.text += " "+i;
i++;
}
stop();