I have three movieclips (used as buttons) on my main MC. The following code swaps the depth of a dynamically loaded image the when I rollOver each movieclip (button).
I want to put the button.rollOver code in a for loop so I dont have to repeat this code for every image loaded.
[AS]
x = 150; // x location of image
Y = 100; // y location of image
onLoad = function () {
_global.nextDepth = 1;
_global.displayed = 0;
};
// Import photos
for (i=1; i<8; i++) {
this.createEmptyMovieClip(“clip”+i+"_mc", i);
this[“clip”+i+"_mc"].createEmptyMovieClip(“photo_mc”, 0);
this[“clip”+i+"_mc"][“photo_mc”].loadMovie(“pics/pic”+i+".jpg");
// put the movieclip at x znd y locations
this[“clip”+i+"_mc"]._x = x;
this[“clip”+i+"_mc"]._y = y;
// scale photos
this[“clip”+i+"_mc"][“photo_mc”]._xscale = 100;
this[“clip”+i+"_mc"][“photo_mc”]._yscale = 100;
button1.onRollOver = function() {
if (displayed != 1) {
nextDepth = _root.getNextHighestDepth();
clip1_mc.swapDepths(nextDepth);
displayed = 1;
}
}
button2.onRollOver = function() {
if (displayed != 2) {
nextDepth = _root.getNextHighestDepth();
clip2_mc.swapDepths(nextDepth);
displayed = 2;
}
}
button3.onRollOver = function() {
if (displayed != 3) {
nextDepth = _root.getNextHighestDepth();
clip3_mc.swapDepths(nextDepth);
displayed = 3;
}
}
}
[/AS]