Hi,
I’m still very new to Flash and tried to write a gallery which loads it’s pictures (from XML) in runtime.
The weird thing is, that if I load the page for the first time not all pictures (or only a few of them) are visible and I can’t click them. When I reload the page with F5 I can click them all.
I think it has something to do with a delay and that the pictures are not completely loaded !?
here is the gallery:
http://www.enthaler.com/Gallery/Gallery.html
and the code how I load my thumbnails:
MovieClip.prototype.loadThumb = function () {
//we need this in each function to have a simple pointer to the Component-Class
var GalleryClass = _level0.instance1;
//tell the GalleryClass what Thumbnail we load right now
GalleryClass.__loadThumbID=this._id;
//load the File
this.loadMovie(GalleryClass.xmlObj.firstChild.childNodes[(__loadThumbID-1)].attributes.thumb);
trace ("inside");
GalleryClass.onEnterFrame = function() {
trace ("jp");
//we need this in each function to have a simple pointer to the Component-Class
var GalleryClass = _level0.instance1;
var thisThumb = GalleryClass.thumbs["thumb" + GalleryClass.__loadThumbID];
var total = thisThumb.getBytesTotal();
var loaded = thisThumb.getBytesLoaded();
if (total != 0 && Math.round(loaded/total) == 1 && thisThumb._width != 0) {
trace (GalleryClass.__loadThumbID + "loaded");
//resize to thumbnail size
var newWidth = GalleryClass.resizePic(GalleryClass.__thumbnailSizeWidth, GalleryClass.__thumbnailSizeHeight, thisThumb._width, thisThumb._height, "width");
var newHeight = GalleryClass.resizePic(GalleryClass.__thumbnailSizeWidth, GalleryClass.__thumbnailSizeHeight, thisThumb._width, thisThumb._height, "height");
thisThumb._width = newWidth;
thisThumb._height = newHeight;
delete this.onEnterFrame;
//redefine id
thisThumb._id = GalleryClass.__loadThumbID;
// continue loading the thumbnails (if needed.. else load Pics)
if (GalleryClass.__loadThumbPriority.length>0) {
var thumbToLoad=GalleryClass.__loadThumbPriority.shift();
GalleryClass.thumbs["thumb"+thumbToLoad].loadThumb();
} else { // else start loading the pictures (if needed)
//make arrow right
if (GalleryClass.__thumbnailPage<Math.ceil(GalleryClass.__picsNumber/thumbsPerPage)) {
GalleryClass.arrowRight.onRelease = function () {
//we need this in each function to have a simple pointer to the Component-Class
var GalleryClass = _level0.instance1;
GalleryClass.thumbs.showThumbnailPage(GalleryClass.__thumbnailPage+1);
}
GalleryClass.arrowRight.alphaTo(100, 0.25);
} else {
GalleryClass.arrowRight.alphaTo(0, 0.3);
}
if (GalleryClass.__loadPicPriority.length>0) {
var picToLoad=GalleryClass.__loadPicPriority.shift();
GalleryClass.pics["pic"+picToLoad].loadPic();
}
}
}
}
}