Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Adding links to images through XML on Flash Slideshow?
Old 09-18-2008, 11:28 PM Adding links to images through XML on Flash Slideshow?
Skilled Talker

Posts: 78
Trades: 0
I have a flash slideshow script driven by XML which I really like; is there any way to link the images through the XML script?

<gallery timer="4" order="sequential" fadetime="2" looping="yes" xpos="0" ypos="0">
<image path="images/banner/banner1.jpg" />
<image path="images/banner/banner2.jpg" />
<image path="images/banner/banner3.jpg" />
<image path="images/banner/banner4.jpg" />
<image path="images/banner/banner5.jpg" />
<image path="images/banner/banner6.jpg" />
<image path="images/banner/banner7.jpg" />
</gallery>
Boar is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-19-2008, 05:36 AM Re: Adding links to images through XML on Flash Slideshow?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
read the path attribute from the image node, convert it into a link href attribute
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-19-2008, 06:44 PM Re: Adding links to images through XML on Flash Slideshow?
Skilled Talker

Posts: 78
Trades: 0
Chris - sorry but I am a bit dull - are you saying that I can link through the XML path from the code sample I have above?

If so could you show me an example? (I should say too that I wanted each banner to go to a different address)

I tried linking it before but could not get it to work, though I am sure I had something wrong.

Thanks for the help!

Last edited by Boar; 09-19-2008 at 06:45 PM..
Boar is offline
Reply With Quote
View Public Profile
 
Old 09-23-2008, 05:50 AM Re: Adding links to images through XML on Flash Slideshow?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
are you saying that I can link through the XML path from the code sample I have above?
Bit on the late side

It depends is the best answer. Without know the script it's impossible to say, but it obviously reads the path attribute for the image, so you just need another attribute for the URI and build the link in the same way it builds the image reference.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-24-2008, 12:11 AM Re: Adding links to images through XML on Flash Slideshow?
Moadib's Avatar
Junior Talker

Posts: 3
Location: Kansas, USA
Trades: 0
Chris,
I'm in the same boat except I'm not an AS coder. I've used this method before but now I need the images to link. I've looked and found other Flash slideshows that load from XML but they all seem to be done in newer versions of Flash than I have (2004 MX). Therefore I can't modify the .fla file for size.

Without being a total leach, can you spell it out for me?

Here's the same code that I'll sure Boar is working with. It's from Todd Dominey's AS2 slideshow. I simply don't know how to add the URL reference into the existing code and then state it in the xml.

I know I'm asking for a freebie but I'd really appreciate the help.

// set random # variables - each must be 0 for first 'while' loop below
var randomNum = 0;
var randomNumLast = 0;

// parent container
var container_mc = this.createEmptyMovieClip("container",0);
// movie clip containers
container_mc.createEmptyMovieClip("loader1_mc",2);
container_mc.createEmptyMovieClip("loader2_mc",1);

// preload watcher
this.createEmptyMovieClip("watcher_mc",100);

// load xml
images_xml = new XML();
images_xml.ignoreWhite=true;
images_xml.onLoad = parse;
images_xml.load("images.xml");

function parse(success) {
if (success) {
imageArray = new Array();
var root = this.firstChild;
_global.numPause = Number(this.firstChild.attributes.timer * 1000);
_global.order = this.firstChild.attributes.order;
_global.looping = this.firstChild.attributes.looping;
_global.fadetime = Number(this.firstChild.attributes.fadetime);
_global.xpos = Number(this.firstChild.attributes.xpos);
_global.ypos = Number(this.firstChild.attributes.ypos);
var imageNode = root.lastChild;
var s=0;
while (imageNode.nodeName != null) {
imageData = new Object;
imageData.path = imageNode.attributes.path;
imageArray[s]=imageData;
imageNode = imageNode.previousSibling;
s++;
}
// place parent container
container_mc._x = _global.xpos;
container_mc._y = _global.ypos;
// parse array
imageArray.reverse();
imageGen(imageArray);
} else {
trace('problem');
}
}

// depth swapping
function swapPlace(clip,num) {
eval(clip).swapDepths(eval("container_mc.loader"+n um+"_mc"));
}

function loadImages(data,num) {
if (i==undefined || i == 2) {
i=2;
createLoader(i,data,num);
i=1;
} else if (i==1) {
createLoader(i,data,num);
i=2;
}
}
function createLoader(i,data,num) {
thisLoader=eval("container_mc.loader"+i+"_mc");
thisLoader._alpha=0;
thisLoader.loadMovie(data[num].path);
watcher_mc.onEnterFrame=function () {
var picLoaded = thisLoader.getBytesLoaded();
var picBytes = thisLoader.getBytesTotal();
if (isNaN(picBytes) || picBytes < 4) {
return;
}
if (picLoaded / picBytes >= 1) {
swapPlace("container_mc.loader2_mc",1);
alphaTween = new mx.transitions.Tween(thisLoader, "_alpha", mx.transitions.easing.Regular.easeOut,0,100,_globa l.fadetime,true);
timerInterval = setInterval(imageGen,_global.numPause,data);
delete this.onEnterFrame;
}
}
}
function imageGen(data) {
// random, or sequential?
if (_global.order=="random") {
// choose random # between 0 and total number of images
while (randomNum == randomNumLast) {
randomNum = Math.floor(Math.random() * data.length);
trace(randomNum);
}
loadImages(data,randomNum);
randomNumLast = randomNum;
} else if (_global.order=="sequential") {
// start at 0, increment to total number of images, then drop back to zero when done
if (p==undefined || p==data.length && _global.looping=="yes") { p=0; } else { break; }
loadImages(data,p);
p++;
} else {
trace ("order attribute in xml isn't correct - must specify either 'random' or 'sequential'");
}
clearInterval(timerInterval);
}
stop();
Moadib is offline
Reply With Quote
View Public Profile
 
Old 09-24-2008, 07:08 AM Re: Adding links to images through XML on Flash Slideshow?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
I don't do any Flash programming at all, I have played with it, but I simply can't find a really useful place for flash

BUT
add another attribute to the image node to hold the URL string, and duplicate this
Code:
 imageData.path = imageNode.attributes.path;
to read the added attribute.

after that you would have to make the stage carry an onclick event and I don't have the Flash compiler installed on my machine to play with the code.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-25-2008, 04:31 PM Re: Adding links to images through XML on Flash Slideshow?
Moadib's Avatar
Junior Talker

Posts: 3
Location: Kansas, USA
Trades: 0
Thanks Chris. I found a couple people who offered to help me out.
Moadib is offline
Reply With Quote
View Public Profile
 
Old 06-02-2010, 04:34 PM Re: Adding links to images through XML on Flash Slideshow?
Pascii's Avatar
Junior Talker

Posts: 1
Trades: 0
Hi Boar, so happy to find this post. Did you ever find a solution for this code? It's the exact same script I use and I cannot figure out how to add individual links to each image. thank you!!

<gallery timer="3" order="random" fadetime="2" looping="yes" xpos="0" ypos="0" >
<image path="/images/test/photo01.jpg"/>
<image path="/images/test/photo02.jpg"/>
<image path="/images/test/photo03.jpg"/>

</gallery>
Pascii is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Adding links to images through XML on Flash Slideshow?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.73283 seconds with 12 queries