Hey got the fading working on an xml driven gallery i made, but after clicking the images a few times the fade effect gets faster and faster and eventually stops working, can anyone see where ive gone wrong??? any help greatly appreciated!
link to test file:
http://lauriedeandrivingschool.co.uk…gal/xgalv2.swf
code: (all in one frame)
var showVar = new Number();
var fadeDone = new Boolean();
showVar = 0;
function unfadeImage(target_mc:MovieClip):Boolean {
fadeDone = false;
if (fadeDone == false) {
target_mc._alpha += 3;
}
if (target_mc._alpha>=100) {
target_mc._alpha = 100;
fadeDone = true;
target_mc._visible = true;
clearInterval(alpha_interval);
showVar = 1;
}
return fadeDone;
}
_global.thumbRefArray = new Array();
_global.thumbRefArray2 = new Array();
var loader = new MovieClipLoader();
var listener = new Object();
var currentThumb = new String();
var index = new Number();
var my_fmt = new TextFormat();
my_fmt.align = "center";
my_fmt.font = "Arial";
my_fmt.size = 9;
index = 0;
listener.onLoadStart = function(target_mc:MovieClip) {
target_mc._alpha = 0;
target_mc.createTextField("loadTxt", 1, 3, 16, 70, 25);
target_mc.loadTxt.setNewTextFormat(my_fmt);
target_mc.loadTxt.text = "Loading.."
index ++
};
listener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number) {
target_mc.loadTxt.text = "(" + bytesLoaded + "/" + bytesTotal + ")";
}
listener.onLoadComplete = function(target_mc:MovieClip) {
target_mc.loadTxt.removeTextField();
//clearInterval(alpha_interval);
if (target_mc <> this.mainLoader) {
do {
fadeDone = unfadeImage(target_mc);
var alpha_interval:Number = setInterval(unfadeImage, 5, target_mc);
} while (fadeDone = false)
} else {
this.mainLoader._alpha = 0;
clearInterval(alpha_interval);
do {
fadeDone = unfadeImage(target_mc);
var alpha_interval:Number = setInterval(unfadeImage, 5, this.mainLoader);
} while (fadeDone = false)
}
//captionTxt.text = "Loading complete"
};
this.nxtBtn._visible = false;
this.prevBtn._visible = false;
this.pgCount.text = "Page 1/2";
myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.onLoad = function(success) {
//portfolioTag = this.firstChild;
numimages = this.firstChild.childNodes.length;
for (i = 0; i < numimages; i++) {
_global.thumbRefArray.push("_level0.thumbLoader.thumbnail" + i);
_global.thumbRefArray2.push("_level0.thumbLoader.thumbnail" + i + ".thumbnail_image");
}
var maxPerPage:Number = 15;
if (numimages <= 15) {
maxPerPage = numimages;
} else {
nxtBtn._visible = true;
}
var cols:Number = 4;
var spacer:Number = 5;
var thumbW:Number = 65;
var thumbH:Number = 50;
loader.addListener(listener);
for (i=0; i < maxPerPage; i++) {
this.picHolder = this.firstChild.childNodes*;
this.thumbHolder = thumbLoader.createEmptyMovieClip("thumbnail"+i, i);
//_global.thumbRefArray.push("_level0.thumbLoader.thumbnail" + i);
this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
currentThumb = "_level0.thumbLoader.thumbnail" + i + ".thumbnail_image";
loader.loadClip(this.picHolder.attributes.thmb, "_level0.thumbLoader.thumbnail" + i + ".thumbnail_image");
this.thumbHolder.title = this.picHolder.attributes.title;
this.thumbHolder.main = this.picHolder.attributes.main;
this.thumbHolder._x = Number(thumbW + spacer) * Number(i % cols);
this.thumbHolder._y = 8;
//this.thumbHolder._y = Number(thumbH + spacer) * int(i / 3);
this.thumbHolder.onRelease = function() {
this.mainLoader._alpha = 0;
loader.loadClip(this.main, mainLoader);
captionTxt.text = this.title;
};
}
};
myPhoto.load("gallery.xml");
not all this code is relevant btw, i just copied from another gallery i made previously
if anyone can see where im going wrong it would be a great help. im sure its something simple i just cant see it!
ST