Below is the code I use for all buttons I make. It’s short and easily. The parameter you pass into the function is mainly the section name and also the button name. Really easy to use…. Create 3 movie clips on the stage called “section1″,”section2”, and “section3”. Inside each movie clip have “in” and “out” labels.

// This function controls all the buttons

createButton = function (item) {

//whatever button your rollover, do this...

this[item].onRollOver = function() {

gotoAndPlay("in");

};

this[item].onRollOut = function() {

gotoAndPlay("out");

};

this[item].onPress = function() {

this._parent.gotoAndPlay(item);

};

};

//These are calls to the function above that basically creates 5 buttons with the following parameters passed in...

createButton("section1");

createButton("section2");

createButton("section3");

Comments are closed.