Hi!
-
I have a script loading thumbs dynamically and I would like them to load one by one with crowing alpha. Now they all load at the same time…
-
I also would like to know how I can get the width/height of the currently loading thumb so that i can center it better.
-
Last, but not least, I want to load a separate thumb-bg movieclip with each thumbnail. Not just filters, I would like a white bg with rounded corners…
Here’s my script, please, any answers are gold worth!
import flash.filters.DropShadowFilter;
var shadowEffect:DropShadowFilter = new DropShadowFilter(0, 45, 0x222222, 50, 3, 3, 1, 3);
var thumbsFilter:Array = [shadowEffect];
function loadThumbs() {
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
thumbnails* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
thumbnails_fn(i);
}
}
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
thumbnails = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
thumbnails* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
//[2].firstChild.nodeValue;
//thumbnails_fn(i);
}
//firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("img/products.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
prevImage();
};
next_btn.onRelease = function() {
nextImage();
};
/////////////////////////////////////
p = 0;
picture._alpha=0;
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
picture_num();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}
function thumbnails_fn(k) {
thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
tlistener.onLoadInit = function(target_mc) {
//target_mc._20 = hit_left._20+(eval("thumbnail_mc.t"+k)._width+5)*k;
target_mc.pictureValue = k;
//target_mc.filters = thumbsFilter;
target_mc.onRelease = function() {
p = this.pictureValue-1;
nextImage();
};
target_mc.onRollOver = function() {
this._alpha = 50;
};
target_mc.onRollOut = function() {
this._alpha = 100;
};
};
tlistener.onLoadProgress = function(target_mc:MovieClip, loaded:Number, total:Number) {
percent = Math.floor(loaded/total*100);
bredd._visible = true;
bredd.text = percent+"%";
thumbnail_mc["t"+k]._alpha=0;
thumbmask._alpha= 0;
thumbnail_mc["t"+k].onEnterFrame = function() {
if (thumbnail_mc["t"+k]._alpha < 100) {
thumbnail_mc["t"+k]._alpha += 10;
thumbmask._alpha += 10;
} else {
delete thumbnail_mc["t"+k].onEnterFrame;
}
}
};
thumbnail_mc["t"+k]._x = (100 + (k*62));
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);
}
Thanks!