Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xml image link to url

Status
Not open for further replies.

creativeconsortium

Technical User
May 9, 2008
2
0
0
GB
Can anyone help? I have modified some Action Script which is working fine. Now I need to link the images that my xml file is loading in to external websites. My A.S. is below followed by the xml.

I think I need to add a 'node' and then the url line to my xml but not sure how and where. The xml bit is easier than the flash AS! I'm not really a programmer so my brain only goes so far before it crases!

Thanks in advance!


leftNavHolder.leftNav._visible = false;
temp._visible = false;
img_holder._alpha = 0;
_global.listLenth = nodes.length;
// For the length of the XML document we are now going to loop through it and build the buttons
function BuildMenu() {
for (i=0; i<_global.listLenth; i++) {
//Duplicate the clips
duplicateMovieClip(leftNavHolder.leftNav, "leftNav"+i, i);
mymc = eval("leftNavHolder.leftNav"+i);
mymc._y = (i*14)+10;
mymc.counter = i;
mymc.button.text = nodes.firstChild.childNodes[0].nodeValue;
mymc.link = nodes.lastChild.childNodes[0].nodeValue;
mymc._alpha = 0;
mymc.onRollOver = function() {
this.gotoAndPlay(2);
};
mymc.onRollOut = function() {
this.gotoAndPlay(26);
};
mymc.onRelease = function() {
trace(this._name);
img = _root.img_holder.img;
_root.image(img, this.link, this);
//getURL(" "_blank");
};
}
image(_root.img_holder.img, leftNavHolder.leftNav0.link, leftNavHolder.leftNav0);
preload(_root.temp.tempimg, leftNavHolder.leftNav1.link, leftNavHolder.leftNav1);
}
function image(img, link, button) {
delete img_holder.onEnterFrame;
img.loadMovie(link);
img._alpha = 0;
img_holder.onEnterFrame = function() {
bytesload = img.getBytesLoaded();
bytesgo = img.getBytesTotal();
percent = (bytesload/bytesgo)*100;
if (percent<100) {
img_holder.text = Math.round(percent)+"%";
//img._alpha = percent
img_holder._alpha = percent;
button._alpha = percent;
} else {
button._alpha = 100;
img_holder.text = "";
//Trigger the image once it's loaded
img.onEnterFrame = function() {
res_image(this);
img_holder._alpha = 100;

};

};
//delete this.onEnterFrame;
}
};

function res_image(imgres) {
//what is imgholder_dimensions
if (imgres._width>imgres._height) {
scale = imgres._width/imgres._height;
imgres._width = 650;
imgres._height = 335;

fadein(imgres);
} else if (imgres._width<imgres._height) {
trace("portrait");
scale = imgres._height/imgres._width;
imgres._width = 650;
imgres._height = 335;
imgres._x = 4;
imgres._y = (335/2-(imgres._height/2));

fadein(imgres);
}
delete imgres.onEnterFrame;
}
function fadein(img) {
img_holder.onEnterFrame = function() {
if (img._alpha>=100) {
img._alpha = 100;
delete this.onEnterFrame;
} else {
img._alpha += 5;
}
};
}
function preload(imgtemp, mylink, mynav) {
delete temp.onEnterFrame;
imgtemp.loadMovie(mylink);
temp.onEnterFrame = function() {
prebytesload = imgtemp.getBytesLoaded();
prebytesgo = imgtemp.getBytesTotal();
prepercent = (prebytesload/prebytesgo)*100;
if (prepercent<100) {
mynav._alpha = percent;
} else {
mynav._alpha = 100;
imgtemp.onEnterFrame = function() {
countervar = mynav.counter;
//Trigger the image once it's loaded
if (countervar<=_global.listLenth) {
nextmc = mynav.counter+1;
trace(eval("leftNavHolder.leftNav"+nextmc));
preload(imgtemp, eval("leftNavHolder.leftNav"+nextmc).link, eval("leftNavHolder.leftNav"+nextmc));
} else {
}
delete this.onEnterFrame;
};
}
};
}
BuildMenu();
stop();
/*
interval code




setInterval(shuffle, 3000);
function shuffle() {
mynum = random(10);
image(_root.img_holder.img, eval("leftNavHolder.leftNav"+mynum+".link"), eval("leftNavHolder.leftNav"+mynum));
}
*/


XML CODE

<?xml version="1.0"?>
<buttons>

<labels>
<button>Anchor Self Storage</button>
<link>images/digital-anchor.jpg</link>
</labels>
<labels>
<button>Antics</button>
<link>images/digital-antics.jpg</link>
</labels>
<labels>
<button>EcoAuditors</button>
<link>images/digital-ecometer.jpg</link>
</labels>
<labels>
<button>Mont Blanc Challenge</button>
<link>images/digital-montblanc.jpg</link>
</labels>
<labels>
<button>Snow Business International (Concept)</button>
<link>images/digital-snow.jpg</link>
</labels>
<labels>
<button>Stuart Lennie</button>
<link>images/digital-lennie.jpg</link>
</labels>
<labels>
<button>The Window Outlet</button>
<link>images/digital-windowoutlet.jpg</link>
</labels>
<labels>
<button>Welcome Telecom</button>
<link>images/digital-welcome.jpg</link>
</labels>
<labels>
<button>Woodchester Cabinet Makers</button>
<link>images/digital-wcm.jpg</link>

</buttons>
 
Not sure if this will help...I am working on XML myself this week...seems the thing to learn now...huh?

My file runs like this:
Code:
<?xml version="1.0"?>

<allphotostuff>
<pic>
	<file>images/image1.gif</file>
	<text>This is a pic of karate cat</text>
</pic>
<pic>
	<file>images/image2.gif</file>
	<text>This is a pic of gun cat</text>
</pic>
<pic>
	<file>images/image2.jpg</file>
	<text>This is a pic of a baby</text>
</pic>
</allphotostuff>

My actionscript looks like this:
Code:
for (i=0; i<this.firstChild.childNodes.length; i++){
			xmlPicArray.push(this.firstChild.childNodes[i].childNodes[0].childNodes)
			xmlTextArray.push(this.firstChild.childNodes[i].childNodes[1].childNodes)
		}

I tired to get that nodeValue thing working and it never did for me. I found that adding one more 'childNodes' got me inside my tags and the information I needed. I ran lots of trace statements to find out how far into my XML list I was getting.
Maybe that will help.


"Credit belongs to the man who is actually in the arena - T.Roosevelt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top