PDA

View Full Version : Flash Help! =[



AshS
03-22-2009, 09:19 AM
hey,

I've been working on this News Headline box for sometime now I'm using actionscript 2 on it, and i've got to a point where i need help.

http://www.urbanreel.com/headlinesbox.swf <-- thats what i have so far.
http://www.urbanreel.com/home <-- if your curious enough to see it in action.

Basically, I want the 'Read More' button to be a link to the article/tutorial/whatever. But I can't get the button to work - I'm loading all the data via XML.


<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images>
<pic>
<image>http://img1.urbanreel.com/flashslide/slideOne.jpg</image>
<caption>How to ollie</caption>
<body>In the first ever tutorial on UrbanReel, Ash teaches you how to ollie on a skate board. So what you waiting for come check it out!</body>
<link>http://urbanreel.com/photos/all</link>
</pic>
etc etc...
</images>

Now, I've got everything else working minus the button. I'll be honest i don't have the faintest idea how to add the button into my code.

The AS Code:


function loadXML(loaded)
{
if (loaded)
{
xmlNode = this.firstChild;
image = [];
description = [];
body = [];
linkurl = [];
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;
body[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
linkurl[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.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];
body_txt.text = body[p];
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
body_txt.text = body[p];

picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
body_txt.text = body[0];

picture_num();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}



So if anyone can offer a solution to my problem I will be very grateful!

Xander
04-16-2009, 05:24 AM
I think getURL might be what you need. From the button call that with the appropriate link. More info at http://www.devarticles.com/c/a/Flash/Basic-Flash-ActionScript-for-Designers/2/. Let me know if it works for you.