PDA

View Full Version : function names and strings



RebuiltJorge
July 8th, 2008, 06:39 AM
ok so i have a loop that goes throught about 4 times and through eace pass assigns an MouseEvent listener to a button, i would like to store the event listener function names in an array like this
var functionNames:Array = new Array("functionOne","functionTwo",functionThree");
myButton.addEventListener(MouseEvent.CLICK,functio nNames[i]);

however this doesn't work, any ideas, thanks

Krilnon
July 8th, 2008, 07:04 AM
You need to have an actual reference to your functions, so code like this might work, depending on where your functions are defined:


var functionNames:Array = new Array(functionOne,functionTwo,functionThree);

RebuiltJorge
July 8th, 2008, 01:20 PM
that works great, thanks!