Groups | Blog | Home
all groups > flash actionscript > july 2007 >

flash actionscript : Applying same function to multiple buttons


BillG-Chicago
7/23/2007 9:59:26 PM
I have a series of buttons for which I want to apply the same function. For
example:

btn1.onRollOver = function() {
this.tabBtn.gotoAndStop("over");
};
btn2.onRollOver = function() {
this.tabBtn.gotoAndStop("over");
};

My question is...how can I call the same function from multiple buttons,
without repeating this same code over and over?
Manno Bult
7/24/2007 1:10:04 AM
Hi,

function generic(){
// do whatever is needed
}

btn1.onRollOver = generic;
btn2.onRollOver = generic;

would do the trick.


[quoted text, click to view]

--
----------
Manno Bult
AddThis Social Bookmark Button