I have three problems left to solve…
[COLOR=Red] 1) I need to have it to where I don’t have to wait for all the thumbs to finish downloading before I can view a “big image”… All the solutions that I have come up with don’t work. I can’t figure out what is wrong, I am assuming that it doesn’t work as it stands because it disrupts the loop when a thumb is clicked but, other than that I don’t know what else to do… [COLOR=Black]DONE[/COLOR][/COLOR]
2)I can’t figure out how to reference the width of the thumbnail images from the main timeline to get them to space correctly… I tried setting the variable in the container with an on enterframe call but i couldnt figure out how to call it from the main stage or what have you…
[COLOR=Red] 3)I tried adding buttons to the “big image” so that when the buttons are clicked they go to the next image or previous image. I was able to get the buttons on there and have them size accordingly by just attaching them to the mc container containing the border for the images, it’s just that i couldn’t get it to cycle forward… i figured that i would use the same code that makes the big image appear and just adjust it so that it says
bigNumber = Number(this._name.substr(9))+1; for the next image and then
bigNumber = Number(this._name.substr(9))-1; for the previous image and then add a function that checks to make sure that if it’s on the last image and you click next it either does nothing or takes it back to the first image and the reverse for if it’s on the first image and you click previous… [COLOR=Black]DONE[/COLOR]
[/COLOR]
here is the code that i am working with…
ActionScript Code:
[FONT=Courier New][LEFT]/* -------------------- variables -------------------- */
var menuSpeed:Number = 4;
var menuDown:Button = menuDown_btn;
var menuUp:Button = menuUp_btn;
menuUp._alpha = 0;
menuUp.enabled = false;
var firstLook:Boolean = true;
var menuButtons:MovieClip = galleryMenu_mc.imagesHolderS_mc;
var galleryMask:MovieClip = galleryMenu_mc.galleryMask_mc;
galleryMask._width = 672;
var imagesHolderS:MovieClip = galleryMenu_mc.imagesHolderS_mc;
var imagesHolderB:MovieClip = galleryMenu_mc.imagesHolderB_mc;
var border:MovieClip = galleryMenu_mc.border;
var descText:TextField = desc_txt;
var imagesInGallery:Array = new Array();
var galleryNames:Array = new Array();
var galleryIntros:Array = new Array();
var descriptions:Array = new Array();
var tracker:Number = new Number();
var whatIsLoading:String = new String();
var thumbMarginX:Number = 520;
/* ------------ image holders positioning -------------------*/
imagesHolderB._x = 85;
imagesHolderB._y = 295;
/* -------------------- dropshadow -------------------- */
import flash.filters.DropShadowFilter;
var shadowEffectS:DropShadowFilter = new DropShadowFilter(2,90, 0x000000, 100, 6, 6, 1, 6);
var shadowEffectB:DropShadowFilter = new DropShadowFilter(10, 90, 0x000000, 100, 10, 10, 1, 3);
var bigFilter:Array = [shadowEffectB];
var thumbsFilter:Array = [shadowEffectS];
/* -------------------- loader and listener -------------------- */
var loader:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
var myListener2:Object = new Object();
loader.addListener(myListener);
loader.addListener(myListener);
myListener.onLoadInit = function(target:MovieClip) {
if (whatIsLoading == "thumb") {
currentThumbnail.percent_txt._visible = false;
currentThumbnail.filters = thumbsFilter;
thumbClickable();
tracker++;
if (tracker<howManyImages) {
loadThumbnail();
} else {
enableThumbs();
}
} if (whatIsLoading == "big") {
target._alpha = 0;
displayBigImage.percent_txt._visible = false;
displayBigImage.filters = bigFilter;
fadeIn();
}
};
myListener.onLoadProgress = function(target:MovieClip, loaded:Number, total:Number) {
percent = Math.floor(loaded/total*100);
if (whatIsLoading == "thumb") {
currentThumbnail.percent_txt._visible = true;
currentThumbnail.percent_txt.text = percent+"%";
} if (whatIsLoading == "big") {
displayBigImage.percent_txt._visible = true;
displayBigImage.percent_txt.text = percent+"%";
}
};
/* -------------------- loading XML -------------------- */
var imageGallery:XML = new XML();
imageGallery.ignoreWhite = true;
imageGallery.onLoad = function(success) {
if (success) {
parseGalleries();
} else {
descText.text = "Sorry the image data just didn't load.";
}
};
imageGallery.load("gallery/slideshow.xml");
/* -------------------- parsing XML -------------------- */
function parseGalleries():Void {
if (imageGallery.firstChild.nodeName == "AlbumBook") {
var rootNode:XMLNode = imageGallery.firstChild;
for (i=0; i<rootNode.childNodes.length; i++) {
if (rootNode.childNodes*.nodeName == "Album") {
currentGallery = rootNode.childNodes*;
imagesInGallery.push(currentGallery.childNodes.length);
galleryNames.push(currentGallery.attributes.title);
galleryIntros.push(currentGallery.attributes.title);
currentGalleryTitle = rootNode.childNodes*.attributes.title;
currentGalleryButton.sectionTitle_txt.text = "0"+(i+1)+" "+currentGalleryTitle.toUpperCase();
for (j=0; j<currentGallery.childNodes.length; j++) {
if (currentGallery.childNodes[j].nodeName == "Slide") {
descriptions.push(currentGallery.childNodes[j].attributes.caption);
}
}
}
}
}
numberOfGalleries = i;
enableButtons(numberOfGalleries);
}
function enableButtons(numberOfGalleries:Number):Void {
for (i=0; i<numberOfGalleries; i++) {
};
thumbsDisplayerS = imagesHolderS;
thumbsDisplayerS._xscale = 23;
thumbsDisplayerS._yscale = 23;
clickedGallery = 0;
howManyImages = imagesInGallery[clickedGallery];
whichGallery = galleryNames[clickedGallery];
descText.text = galleryIntros[clickedGallery];
currentRow = 0;
currentColumn = 0;
loadThumbnail();
enableGalleryNavigation();
}
function loadThumbnail() {
currentThumbnail = thumbsDisplayerS.attachMovie("thumbnail holder","thumbnail"+(tracker+1), thumbsDisplayerS.getNextHighestDepth());
target = currentThumbnail.thumbImage_mc;
currentThumbnail.onRollOver = function():Void {
this.gotoAndStop(2);
this._xscale=105;
this._yscale=105;
};
currentThumbnail.onRollOut = function():Void {
this.gotoAndStop(1);
this._xscale=100;
this._yscale=100;
};
if (tracker == 0) {
currentColumn = 0;
} else {
currentColumn += 1;
}
currentThumbnail._x = currentColumn*thumbMarginX;
currentThumbnail.percent_txt._visible = true;
thumbNumber = currentThumbnail._name.substr(9);
thumbPath = "gallery/"+whichGallery+"/"+thumbNumber+".jpg";
whatIsLoading = "thumb";
loader.loadClip (thumbPath, target);
}
function thumbClickable():Void {
currentThumbnail.onPress = function() {
removeMovieClip(displayBigImage);
bigNumber = this._name.substr(9);
displayBigImage = imagesHolderB.attachMovie("big image holder", "bigImage_mc", imagesHolderB.getNextHighestDepth());
target = displayBigImage.imagesHolderB_mc;
bigImagePath = "gallery/"+whichGallery+"/"+bigNumber+".jpg";
whatIsLoading = "big";
loader.loadClip(bigImagePath,target);
if (clickedGallery>0) {
var descPosition:Number = 0;
for (i=0; i<clickedGallery; i++) {
descPosition += imagesInGallery*;
}
descPosition = descPosition+Number(bigNumber)-1;
imageDesc = descriptions[descPosition];
} else {
imageDesc = descriptions[Number(bigNumber)-1];
}
descText.text = imageDesc;
}
};
function disableThumbs():Void {
for (i=0; i<howManyImages; i++) {
thumbsDisplayerS["thumbnail"+(i+1)].enabled = false;
}
}
function enableThumbs():Void {
for (i=0; i<howManyImages; i++) {
thumbsDisplayerS["thumbnail"+(i+1)].enabled = true;
}
}
function fadeIn():Void {
target.onEnterFrame = function():Void {
this._alpha += 10;
if (this._alpha>=100) {
delete this.onEnterFrame;
this._alpha = 100;
}
};
}
function enableGalleryNavigation():Void {
menuDown.onPress = function() {
if (firstLook) {
menuUp._alpha = 100;
menuUp.enabled = true;
firstLook = false;
}
var menuTop:Number = imagesHolderS._width-Math.abs(imagesHolderS._x);
if (imagesHolderS._x<=0 && menuTop>=672) {
var targetPos:Number = imagesHolderS._x-300;
menuDown.enabled = false;
menuUp.enabled = false;
imagesHolderS.onEnterFrame = function():Void {
imagesHolderS._x += (targetPos-imagesHolderS._x)/menuSpeed;
if (imagesHolderS._x<=(targetPos+0.8)) {
imagesHolderS._x = Math.round(targetPos);
delete imagesHolderS.onEnterFrame;
menuDown.enabled = true;
menuUp.enabled = true;
}
};
}
};
menuUp.onPress = function() {
var menuTop:Number = imagesHolderS._width-Math.abs(imagesHolderS._x);
if (imagesHolderS._x<0 && menuTop>0) {
var targetPos:Number = imagesHolderS._x+300;
menuDown.enabled = false;
menuUp.enabled = false;
imagesHolderS.onEnterFrame = function():Void {
imagesHolderS._x += (-imagesHolderS._x+targetPos)/menuSpeed;
if (imagesHolderS._x>=(targetPos-0.8)) {
imagesHolderS._x = Math.round(targetPos);
delete imagesHolderS.onEnterFrame;
menuDown.enabled = true;
menuUp.enabled = true;
}
};
}
};
}[/LEFT]
[/FONT]