At the point where I though I had a handle on this but now just overwhelmed :-/
here’s the xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<ItemList>
<item type='prints'>
<itemID>1</itemID>
<name>New Print</name>
<description>just testing prints</description>
<sizes>
<sizeID>1</sizeID>
<size>5x7</size>
<quantity>1000</quantity>
<price>100</price>
<thumbnail>http://www.2aweek.com/EandM/www/images/prints/thumb/1-5x7.jpg</thumbnail>
<original>http://www.2aweek.com/EandM/www/images/prints/full/1-5x7.jpg</original>
</sizes>
<sizes>
<sizeID>2</sizeID>
<size>8x10</size>
<quantity>100</quantity>
<price>10</price>
<thumbnail>http://www.2aweek.com/EandM/www/images/prints/thumb/1-8x10.jpg</thumbnail>
<original>http://www.2aweek.com/EandM/www/images/prints/full/1-8x10.jpg</original>
</sizes>
</item>
<item type='t_shirts'>
<itemID>3</itemID>
<name>New Shirt</name>
<description>just testing shirts</description>
<sizes>
<sizeID>4</sizeID>
<size>Men Small</size>
<quantity>15</quantity>
<price>10</price>
<thumbnail>http://www.2aweek.com/EandM/www/images/t_shirts/thumb/3-men_small.jpg</thumbnail>
<original>http://www.2aweek.com/EandM/www/images/t_shirts/full/3-men_small.jpg</original>
</sizes>
</item>
</ItemList>
And now the as
//set spacing between thumbnails
var thumb_spacing = 40;
//create function to generate our xml
function generateItems(items_xml){
//create shortcut variable to the <item> elements in the xml
var myItems = items_xml.firstChild.childNodes;
//loop through all the <item> elements
for (var i = 0; i < myItems.length; i++){
//only do the following if the attribute type matches "prints"
if (myItems*.attributes.type == "prints") {
//create variable to hold each item
var itemize = myItems*;
//create var of path to <size> element in xml
var sizes = itemize.childNodes[3];
//use sizes var to nested loop through each childnode of <sizes> in xml
for (var s = 0; s < sizes.childNodes.length; s++){
//creat var to hold each size item (indexing)
var size = sizes.childNodes[s];
trace(size.nodeName+": "+size.firstChild.nodeValue);
//menu_mc.loadMovie(size.childNodes[4].firstChild.nodeValue);
}
//create var to hold the current large photo (indexing)
var currentPicture = sizes*;
//create var which holds a newly created moviclip for each thumbnail inside menu_mc (so event handlers work on them)
var currentThumb_mc = menu_mc.createEmptyMovieClip ("thumbnail_mc"+i,i);
//space the thumbs accordingly
currentThumb_mc._x = i * thumb_spacing;
var thumbnail = currentPicture.childNodes[4];
currentThumb_mc.createEmptyMovieClip("thumb_container",0);
currentThumb_mc.thumb_container.loadMovie (thumbnail.firstChild.nodeValue);
//currentThumb_mc.itemID = currentPicture.firstChild.firstChild.nodeValue;
//currentThumb_mc.itemName= currentPicture.childNodes[1].firstChild.nodeValue;
//currentThumb_mc.description = currentPicture.childNodes[2].firstChild.nodeValue;
/*
currentThumb_mc.onRollOver = currentThumb_mc.onDragOver = function(){
info_txt.text = this.title;
}
currentThumb_mc.onRollOut = currentThumb_mc.onDragOut = function(){
info_txt.text = "";
}
currentThumb_mc.onRelease = function(){
image_mc.loadMovie(this.image);
description_lv.load(this.description);
}*/
}
}
}
var items_xml = new XML();
items_xml.ignoreWhite = true;
items_xml.onLoad = function(success){
if (success) generateItems(this);
else trace("Error loading XML file");
}
items_xml.load("item.xml");
What i’ve done was try to use senoculars xml portfolio as a starting point and using it for my application. My goal is a shopping experience as you can see from the xml. Say for tshirts, I’d like to display all the thumbs for each shirt and a respected original photo when thumbs are clicked. Each thumb that is clicked would also show the respected price, etc.
So I’m not sure I’m still going about this the right way, the nested loop has me all screwed up 6 ways from sunday. I’ve attached an fla if that’d help too.
If anyone can point me in some direction that’d be awesome.
Or if someone can help on the side, I could re-imburse somehow.
Thanks!