-
help adding URL to XML loaded images in gallery?
Hi,
My actionscript knowledge is not very good and I am having an extremely difficult time trying to get this to work. I have a gallery that is running perfectly that I bought at flashden and then have adjusted to fit my needs. However, I can't figure out how to add in this one piece of functionality that I need.
The XML loads in the thumbnail and when the thumbnail is clicked a larger image comes up in a movie clip above it. I want users to be able to click again on that larger XML loaded image to open a hi-res version of the same image in a separate window. How can I add this? I have posted the flash AS and the XML below.
Thanks for any help someone can provide!
FLASH code
//On frame 1 the below code is on the gallery_MC
//Load XML Data
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
large = [];
txt = [];
total = xmlNode.childNodes.length;
for (i=0; i<=total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
large[i]= xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
txt[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
gotoAndStop(2);
}
} else {
msg.text = "Error loading XML";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("content.xml");
stop();
//On frame 2 the below code is on the gallery_MC
//Set your image size here
imageWidth = 95;
imageHeight = 71;
//Function for on press events
clickAction = function (obj) {
loadMovie(obj.large, this.holder);
this.info_mc._alpha = 0
this.holder._alpha = 0
this.info_mc.info = obj.txt;
this.info_mc.num = obj.i+" / "+total;
};
loadMovie(large[0], this.holder);
this.info_mc.info = txt[0];
this.info_mc.num = 1+" / "+total;
//Builds menu content based on XML date
for (i=0; i<total; ++i) {
this.content_mc.image_mc.duplicateMovieClip("image _mc"+i, i);
this.content_mc["image_mc"+i]._x = imageWidth*i;
loadMovie(image[i], this.content_mc["image_mc"+i].holder);
this.content_mc["image_mc"+i].i = i+1
this.content_mc["image_mc"+i].large = large[i];
this.content_mc["image_mc"+i].txt = txt[i];
this.content_mc["image_mc"+i].bttn._width = imageWidth;
this.content_mc["image_mc"+i].bttn._height = imageHeight;
this.content_mc["image_mc"+i].preloader._x = imageWidth/2;
this.content_mc["image_mc"+i].preloader._y = imageWidth/2;
}
//Set boundry mask
content_mc.setMask(mask_mc);
boundryWidth = mask_mc._width;
boundryHeight = mask_mc._height;
//Buffer size left and right of menu
buffer = (imageWidth)*2;
//Detect mouse position
this.onMouseMove = function() {
if (this._xmouse>0 && this._xmouse<(boundryWidth)) {
if (this._ymouse>0 && this._ymouse<(boundryHeight)) {
ratio = this._xmouse/boundryWidth;
diff = content_mc._width-boundryWidth+buffer;
destX = Math.floor(-ratio*diff)+buffer/2;
}
}
};
//Scroll easing
this.onEnterFrame = function() {
content_mc._x += (destX-content_mc._x)/5;
if (content_mc._x>0) {
content_mc._x = 0;
} else if (content_mc._x<(boundryWidth-content_mc._width)) {
content_mc._x = boundryWidth-content_mc._width;
}
};
stop();
XML CODE
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<content>
<gallery>
<image>thumbs/londonThumb.jpg</image>
<large>images/londonLargeS.jpg</large>
<txt>Created in March '05 with Maya 6.0 and Adobe Photoshop CS. Entire project was modeled in NURBS.</txt>
<url>www.temp.com</url>
</gallery>
<gallery>
<image>thumbs/coffeeThumb.jpg</image>
<large>images/coffeeLargeS.jpg</large>
<txt>Created in February '05 with Maya 6.0. Texturing and lighting by Timothy A. Nice in Maya 6.0 and Photoshop CS. Entire project was modeled in NURBS.</txt>
<url>www.temp.com</url>
</gallery>
<gallery>
<image>thumbs/crateThumb.jpg</image>
<large>images/crateLargeS.jpg</large>
<txt>Created in September '05 with Maya 6.0 and Photoshop CS. Entire project was modeled in NURBS.</txt>
<url>www.temp.com</url>
</gallery>
<gallery>
<image>thumbs/FYCThumb.jpg</image>
<large>images/FYCLargeS.jpg</large>
<txt>FYC - "She Drives Me Crazy" (still frame)</txt>
<url>www.temp.com</url>
</gallery>
<gallery>
<image>thumbs/loft1Thumb.jpg</image>
<large>images/loft1LargeS.jpg</large>
<txt>Created January '06 - May '06 using Maya 7.0, Photoshop CS2, and STG Pro. Project was a modeled in a mixture of NURBS and polygons.</txt>
<url>www.temp.com</url>
</gallery>
<gallery>
<image>thumbs/loft2Thumb.jpg</image>
<large>images/loft2LargeS.jpg</large>
<txt>Created January '06 - May '06 using Maya 7.0, Photoshop CS2, and STG Pro. Project was a modeled in a mixture of NURBS and polygons.</txt>
<url>www.temp.com</url>
</gallery>
<gallery>
<image>thumbs/loft3Thumb.jpg</image>
<large>images/loft3LargeS.jpg</large>
<txt>Created January '06 - May '06 using Maya 7.0, Photoshop CS2, and STG Pro. Project was a modeled in a mixture of NURBS and polygons.</txt>
<url>www.temp.com</url>
</gallery>
</content>
Last edited by popflier; 04-29-2008 at 06:14 PM.
-
okay first understand what is happening - here's the code loading the XML data, with some comments on what it is doing and an extra line to load in more data...
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
large = [];
txt = [];
up to here it is just starting the process to load information and making sure variables are defined and empty. We need another variable, so let's add in the following:
hires = [];
total = xmlNode.childNodes.length;
for (i=0; i<=total; i++) {
this starts the process of loading data and tells it to keep going until there is not more data.
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;this loads in the image path, or the contents of tag number 0 (the first one) after 'gallery' - in this case the <image> tag.
large[i]= xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;this loads in the large image path, or the contents of tag number 1 (the second one) after 'gallery' - in this case the <large> tag.
txt[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;this loads in the text, or the contents of tag number 2 (the third one) after 'gallery' - in this case the <txt> tag.
now you have nothing else loaded. I hope you can figure out what you need to do to load in the url, but just in case, here's the code:
hires[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;this loads in the path to the hi res version, or the contents of tag number 3 (the fourth one) after 'gallery' - in this case the <txt> tag.
Okay, a little note here - your XML has a tag called <url> where I am using the variable hires. I don't think any issue would come up from this - I have successfully loaded in data into differently named variables before. However, to make things easier, I would rename the tag in the xml file to <hires> just to easily see what is going where in the future. I wouldn't use the variable 'url' as it can cause conflicts within the code.
gotoAndStop(2);
}
It is now done! The rest is for if something went wrong... hopefully it won't come into play.
} else {
msg.text = "Error loading XML";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("content.xml");
stop();
-
Well, my last post was meant to cover it all, and I hope to soon; but I have a minor emergency and cut if off early. For now it shows you how to actually load that url into a variable in flash, and maybe helps you understand what is going on. I'll try to get back and describe how to add in the extra click on the large MC to open the url soon - if someone hasn't beaten me to it by then.
-
Originally Posted by kargrafx
Well, my last post was meant to cover it all, and I hope to soon; but I have a minor emergency and cut if off early. For now it shows you how to actually load that url into a variable in flash, and maybe helps you understand what is going on. I'll try to get back and describe how to add in the extra click on the large MC to open the url soon - if someone hasn't beaten me to it by then.
Thanks for the explanation. This all makes allot more sense now. I wasn't even sure what I was looking at in the script and your notes have helped quite a bit.
I have made the changes to both the flash file and the xml that you suggested. I hope the emergency isn't too bad and if you are able to come back to help fill me in on setting up the extra click on the large MC that would be great. If not, that's okay. I appreciate any assistance I can get and thanks for your time.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|