I wrote quite a bit of code without ever testing it first, but of course the first time I ran the SWF it didn’t work. The only problem is that I can’t figure out why. Syntax is just fine, Flash didn’t give me any errors there. No, actually, this code seems to do absolutely nothing except say “Read www.vexiron.com” in the status bar.
I wonder if any of you could be nice enough to take the time and look this over. Its pretty simple what im trying to do, if you look at it.
var maxSpots:Number = 6; // maximum number of spots available for images on one page
var thumbspacing:Number = 85; // spacing ALL AROUND the thumbnail, not just L and R, but top and bottom as well.
var leftPadding:Number = 72; // left padding for thumbs
var topPadding:Number = 100; // top padding for thumbs
var genComplete:Boolean = false; // true when the page has been displayed. (to enable clicking)
var currentPage:Number = 1; // current page of events/thumbs being displayed, reference for call to GenerateThumbs()
var myLoader = new MovieClipLoader();
var myLoaderObj = new Object();
myLoader.addListener(myLoaderObj);
myLoader.onLoadComplete = function(targetMC) {
loadingtext = "";
targetMC._alpha = 100;
targetMC._visible = true;
fadeIn(targetMC);
}
myLoader.onLoadStart = function(targetMC) {
loadingtext = "Loading . . .";
}
function GenerateThumbs(gallery_xml, eventNumber:Number) { // fades in maxSpots number of thumbnails separated by thumbSpacing on a given page of events/thumbs from picArray
var gallery = gallery_xml.firstChild; // define the gallery
var eventsArray = gallery.childNodes; // array that contains the events
if (eventNumber <= 0) { // IF ITS THE EVENTS THAT NEED TO BE DRAWN.
// draw maxSpots thumbs for the events
var eventThumbURL = eventsArray[eventsArray.length - 1].nodeValue;
var startingIndex:Number = maxSpots * (currentPage - 1);
for (i = startingIndex; i < eventsArray.length - 1; i++) { // iterate through the events, position each one
var nextRow = false;
currentEvent = eventsArray*; // define the event
gallerycontainer_mc.createEmptyMovieClip("event" + i + "_mc", i); // create the MC
var newClip = gallerycontainer_mc["event"+i+"mc"];
newClip._visible = false; // make it invisible
if (!nextRow) { // if it is the first row
newClip._y = topPadding; // set the Y to the first row's y
if (i == 0) {
newClip._x = leftPadding; // set the X
}
else if (i <= (maxSpots / 2) - 1) {
newClip._x = newClip._x + thumbSpacing; // set the X
}
else {
nextRow = true;
}
} else { // if it is the second row
newClip._y = topPadding + 150 + thumbSpacing; // set the Y to the second row's Y
if (i == 0) {
newClip._x = leftPadding; // set the X
}
else if (i <= (maxSpots / 2) - 1) {
newClip._x = newClip._x + thumbSpacing; // set the X
}
}
myLoader.loadClip(eventThumbURL, newClip);
}
}
else { // draw the given thumbs for the pictures on the specified page in the specified event
// CODE FOR GENERATING THUMBS FOR PICS GOES HERE!
//var picsArray = eventsArray[eventNumber-1].childNodes; // array that contains the pics
}
}
var gallery_xml = new XML();
gallery_xml.ignoreWhite = true;
gallery_xml.onLoad = function(success){
if (success) {
GenerateThumbs(this, -1); // feed GenerateThumbs -1 so it loads the events
}
else {
loadingtext = "Error!";
}
}
gallery_xml.load("piclist.xml");
I’ve double checked the URL’s and they should all be right, I don’t see why nothing is being displayed.
Quick rundown of what this code does:
So first we define all the variables needed, obviously, then I defined the onLoadComplete and onLoadStart so that Flash knows what to display when the event thumbnails are being loaded and finished loading.
Then the generate thumbs method, the main part of this code, basically just does this: for every child of gallery, namely events, make a new movieclip and position it properly on screen so that we form a maximum of 6 event thumbnails at once, and which ones are decided by the current page. i havent implemented the buttons for changing pages yet.
anyway, after it positions the movieclip it loads the proper image into it, and then makes the movieclip visible. trouble is, nothing becomes visible. below that, i havent even begun to implement the drawing of the IMAGE thumbnails, seeing as I cant get the event thumbnails to work. below THAT, its just making the XML object and calling GenerateThumbs with the parameter -1 to make it generate the events.
phew, what a mindjob, at least for me. but see if you can help me out, i really have no idea whats wrong.
Thanks in advance. :beam:
quick edit: to see where the code gets to while running it on my server, i added some loadedtext="" statements to act as a tracer (see updated code above) and the output is always “step 7”. dont know if that will help you pros but I hope so.
quickedit2: updated the code with some changes, not that much different
quickedit3: FLA IS HERE: www.vexiron.com/spekpreview/gallery.fla