all groups > flash (macromedia) > july 2006 >
You're in the

flash (macromedia)

group:

Very Basic Question: Hyperlinks in Flash from XML


Very Basic Question: Hyperlinks in Flash from XML mwb2069
7/10/2006 11:56:25 PM
flash (macromedia):
Please help. Just looking for the line of code that will display hyperlinks in
my flash photo slideshow from my XML document.

Here's my sample xml:

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<images>
<pic>
<image>images/tiger.gif</image>
<headline>Tiger Kills Man</headline>
<thumbnail>images/tiger_thumbnail.gif</thumbnail>
<caption>Tiger killed man at 9:00pm.. </caption>
<preview>Crazy tiger killed man at 9:00pm. No witnesses. Click here for
more.</preview>
</pic>

And heres the first half of my .as file

Here is my as code (pretty much from tutorials here).


function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
thumbnails = [];
caption = [];
preview = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
thumbnails[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
caption[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
preview[i] = xmlNode.childNodes[i].childNodes[4].firstChild.nodeValue;
thumbnails_fn(i);
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("pics.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
prevImage();
};
next_btn.onRelease = function() {
nextImage();
};
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
caption_txt.text = caption[p];
preview_txt.text = preview[p];
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
caption_txt.text = caption[p];
preview_txt.text = preview[p];
picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
caption_txt.text = caption[0];
preview_txt.text = preview[0];
picture_num();
}



THANK YOU!
Re: Very Basic Question: Hyperlinks in Flash from XML Boerboel649
7/11/2006 6:26:31 PM
Re: Very Basic Question: Hyperlinks in Flash from XML Wolf van Ween
7/11/2006 8:44:17 PM
I am trying to help, but you don't make it too easy for us.
What exactly is your problem?
You wrote "Just looking for the line of code that will display hyperlinks in
my flash photo slideshow from my XML document."
1. I can see no hyperlinks in your XML document.
2. Where do you want to display those hyperlinks?

Other than that a couple of remarks:
- please use the board's "attach code" feature, otherwise some code gets
misinterpreted as formatting, making it very difficult to find mistakes.
- your XML lacks a </images> tag at the end
- the if (loaded == filesize) in the nextImage() function means the next
button (and key) only work when the previous image has loaded fully. Is that
desired behaviour?
- wouldn't you want to delete the onEnterFrame function once a picture is
loaded and faded in?

Just my 2 cents
Wolf
AddThis Social Bookmark Button