I have the following lines of code that i want to optimize:
[AS]furniture1.onRollOver = function() {
duplicate(furniture1);
};
furniture2.onRollOver = function() {
duplicate(furniture2);
};
furniture3.onRollOver = function() {
duplicate(furniture3);
};
furniture4.onRollOver = function() {
duplicate(furniture4);
};[/AS]
I tried the following but it wasnt working for me:
[AS]var numOfFurniture = 4;
for (var i = 1; i <= numOfFurniture; i++) {
var furn = this[“furniture” + i];
furn.onRollOver = duplicate(furn);
}[/AS]
how can i optimize this so i dont have to write an onRollOver statement for every piece of furniture i add?
thanks in advance.