Groups | Blog | Home
all groups > flash actionscript > october 2006 >

flash actionscript : Reusing a function


jmarchan
10/23/2006 10:19:38 PM
I have 4 buttons that are supposed to use the same function when they are
clicked, but when I assign the onRelease event to each button, the function
gets executed... Can somebody please tell me what am i doing wrong?



loadVarsVideos.onLoad = function(success:Boolean) {
if (success) {
arrVideos = loadVarsVideos.videos.split(",");
arrDesc = loadVarsVideos.desc.split(",");
for (j=0; j<cantidad; j++) {

this["boton"+j].onRelease = cargarBoton(arrVideos[j]);
} // fin del for
} else {
trace("Error loading/parsing LoadVars.");
}
};
NSurveyor
10/24/2006 12:27:41 AM
You are setting the onRelease handler as the RETURN value of the cargarBoton function. Try this:
this["boton"+j].j = j;
this["boton"+j].onRelease = function(){
cargarBoton(arrVideos[this.j]);
AddThis Social Bookmark Button