[RESOLVED] swapDepths - spot the flaw?!
I have loaded several large images into clips at different levels within a container clip.
I have thumbnails corresponding to these larger images. When I click a thumbnail, I want the right image to jump to the top of the stack. I'm doing this by calculating which image is currently at the top, and then swapping depths.
The code below works for about 10+ clicks - the right image fades in ontop of the previous image,... but then it starts to mess up, and other images are visible underneath the fade in effect.
Can anyone see what's wrong just from looking at the code?
Actionscript Code:
function makeBtns(tot:Number) {
for (p=1;p<=tot;p++) {
if (p==1) {
_root["loader"]["ntemp"+p]._alpha = 100;//set the first picture as visible...
} else {
_root["loader"]["ntemp"+p]._alpha = 0;//everything else invisible.
}
_root["view"]["thmb_mc"+p].onPress = function() {
id = this._name.substr(7,2);
fadeIn(id,tot);
}
}
};
function fadeIn(pic:Number,tot:Number) {
picin = _root["loader"]["ntemp"+pic];
prev = _root["loader"].getInstanceAtDepth(tot);
picin.swapDepths(prev);
for (v=1;v<=tot;v++) {
if (v==pic) {
_root["loader"]["ntemp"+pic]._alpha = 0;
}
}
picin.onEnterFrame = function() {
if (this._alpha < 100) {
this._alpha += 15;
} else {
delete picin.onEnterFrame;
}
}
};
As always, thanks for any suggestions.