The output window displayed this.
"images/undefined"
Printable View
The output window displayed this.
"images/undefined"
As expected. See, the scope of the XML object doesn't go beyond the object itself. That's why in my example you see the use of arrays. What is the best thing to do when working with XML in a robust application like this, is to add the data to variable arrays or other variables so that you can manipulate the data afterwards.
You're doing everything within the onLoad() event. There is nothing wrong with it, but for clarity of code I suggest you move the code outside. Also, you're declaring a lot of variables that don't come into use. Lastly, you're calling a "title" attribute from your XML which doesn't exist.
I'm assuming you'll add the title in -- otherwise your caption in Lightbox will read "undefined";
So, anyway...cleaning up your code, I get this:
When you click a thumbnail, it'll trace the LightboxDelegate call (and probably launch a blank browser window). When you embed it, it should work as intended with Lightbox++.Code:var xml:XML = new XML();
xml.ignoreWhite = true;
var totalImages:Number = new Number();
var count:Number = 0; // Variable that counts how many movieclips have rendered thus far
var yPos:Number = 30; // Initial _y coordinate of the first row
var spacing:Number = 55;
xml.onLoad = function(success) {
if (success) {
totalImages = this.firstChild.childNodes.length;
loadImages();
}
};
function loadImages() {
for (i=0; i<totalImages; i++) {
var thmbPath:String = xml.firstChild.childNodes[i].attributes.thmb;
var holder:MovieClip = this.createEmptyMovieClip("holder"+i, this.getNextHighestDepth());
var thumbnail:MovieClip = holder.createEmptyMovieClip("thumb", 1);
holder.id = i;
thumbnail.loadMovie(thmbPath);
holder.onRelease = function() {
trace("javascript:LightboxDelegate('" + xml.firstChild.childNodes[this.id].attributes.src + "','" + xml.firstChild.childNodes[this.id].attributes.title + "')");
getURL("javascript:LightboxDelegate('" + xml.firstChild.childNodes[this.id].attributes.src + "','" + xml.firstChild.childNodes[this.id].attributes.title + "')");
}
if (count == 8) { // if count = 8, we're at the end of the row
count = 0; // reset count to 0
yPos = yPos + 70; // incease the _y coordinate for the next row (100 = height of element plus padding)
}
holder._x = count*spacing // set _x coordinate
holder._y = yPos; // set _y coordinate
count++; // increase count by 1
};
}
xml.load("wedding.xml");
HTH
Alright, this is starting to work now, thanks so much for sticking with it and helping me with this, the only issue I am confronting now is the bottom bar with the image description and the close button does not fit the picture, it seems to stay one generic size.
Click Here Go to portfolio and select one of the last 3 pictures you will see what I mean.
I assume this is a javascript issue now.
*Corr
Ok the last AS I had a better understanding of and things were a bit more clear and easier for me to edit (i.e. I could move the thumbnails and apply drop shadows as they were in a MovieClip, this new system seems to set the thumbnails in the top left corner and they don't work off the thumbnail Movie Clip I had.
Is there anyway to still edit the thumbnail position and possibly add effects?
Hey Nate,
I'm not able to replicate that in Fx 2 and IE7 on a PC. The popup box is resizing for me.
Nevermind,
What I did was made a MC and placed the AS in it, now I am able to reposition the mc containing the AS and apply drop shadows and everything still works.
Medyman, you are a huge asset to this community, I cannot thank you enough for your assitance and education on this matter.
-- Nate