You are here: DEVPPL Forum Programming Flash Forum
NOTIFICATIONS
54.067
MEMBERS
15.678
TOPICS
62.243
POSTS
  562
FLASH GAMES
7.740
TUTORIALS
 

Login

E-mail:
Password:

Make an image a hyperlink

0

Loading

Make an image a hyperlink

Postby Anyonewannaspud » Sat Apr 05, 2008 4:37 pm

Hello everyone,

I've got a slideshow that loads the images by XML through flash. It all works fine but I was wondering if it was possible to make the image a hyperlink and assign a target for it?

My XML is:
<xml>
<photo>
<thumb>photo_01.jpg</thumb>
</photo>
<photo>
<thumb>photo_02.jpg</thumb>
</photo>
<photo>
<thumb>animation_01.swf</thumb>
</photo>
<photo>
<thumb>photo_04.jpg</thumb>
</photo>
<photo>
<thumb>photo_05.jpg</thumb>
</photo>
</xml>


is it something i can write here or do i need to show the flash code as well?

thanks very much :)
Anyonewannaspud
 
Reputation: 0
Posts: 8
Joined: Mon Oct 01, 2007 6:05 pm
Highscores: 0
Arcade winning challenges: 0

Make an image a hyperlink - Sponsored results

Sponsored results

Login to get rid of ads

 

0

Loading

Postby Rasmus Lindström » Sun Apr 06, 2008 10:28 am

You'll have to change the XML code to send a link for every photo too, like this:
Code: Select all
<photo>
<thumb>photo_01.jpg</thumb>
<link>http://www.devppl.com</link>
</photo>


The rest should be handled by flash, so you'll have to post that code too.
Rasmus Lindström
Site Admin
 
Reputation: 18
Posts: 2829
Joined: Tue Aug 17, 2004 2:07 pm
Location: Sweden
Highscores: 1
Arcade winning challenges: 0
0

Loading

Postby Anyonewannaspud » Sun Apr 06, 2008 10:38 am

Ah thank you. The flash part is on a lot of keyframes, I'm not sure what part you would need so I'll post them all.

First Keyframe:

Code: Select all
itemlist = new Array();
itemlist_xml = new XML();
itemlist_xml.ignoreWhite = true;


itemlist_xml.onLoad = function(success) {
   if (success) {
      var startTime = getTimer();
      var items_xml = itemlist_xml.firstChild;
      for (var i = 0; i<items_xml.childNodes.length; i++) {
         var trackData = new Object();
         for (var j = 0; j<items_xml.childNodes[i].childNodes.length; j++) {
            trackData[items_xml.childNodes[i].childNodes[j].nodeName] = items_xml.childNodes[i].childNodes[j].firstChild.nodeValue;
         }
         itemlist.push(trackData);
      }
   } else {
      trace("Error loading itemlist.");
   }

   // clean up after ourselves
   delete itemlist_xml;
   play();
};
itemlist_xml.load("photo.xml");
stop();




Next Keyframe:

Code: Select all
//trace (itemlist.length);
//trace (itemlist[0]["thumb"]);
this.createEmptyMovieClip("strip", this.getNextHighestDepth());
var i = 0;
var w = 0;




Next Keyframe

Code: Select all
trace("Item "+i+" is file "+itemlist[i]["thumb"]);
// create a placeholder for the new photo
this.strip.createEmptyMovieClip("photo"+i, this.strip.getNextHighestDepth());
// now load in the photo
this.strip["photo"+i]._alpha = 0;
this.strip["photo"+i].loadMovie("photos/"+itemlist[i]["thumb"]);




Next Keyframe:

Code: Select all
if (this.strip["photo"+i].getBytesLoaded() != this.strip["photo"+i].getBytesTotal()) {
   gotoAndPlay(_currentframe-1);
}





Next Keyframe:

Code: Select all
this.strip["photo"+i]._x = w;
this.strip["photo"+i]._y = 0;
this.strip["photo"+i]._alpha = 100;
w = w+this.strip["photo"+i]._width;
i++;
if (i<itemlist.length) {
   gotoAndPlay("loadimage");
}





Next Keyframe:

Code: Select all
this.strip.onEnterFrame = function() {
   if ((_level0._ymouse>0) and (_level0._ymouse<447)) {
      // work out how far to move strip from mouse's x position
      dx = (_level0._xmouse-358)/-30;
      // get the strips position, and put it temporarily into 'cx'
      cx = this._x;
      // now add on how much to move it by
      cx = cx+dx;
      // check it hasnt gone too far to the right
      if (cx>0) {
         cx = 0;
      }
      // or the left ( 'this._width' is the strip or 'this objects' width )
      if (cx<(716-this._width)) {
         cx = 716-this._width;
      }
      // temporary position cx is okay, so move the strip to that new position
      this._x = cx;
   }
};
stop();



Thank you very much again for your help and hope this is not too confusing. If it would be easier to see the flash file i can upload it, just let me know :)

cheers!
Anyonewannaspud
 
Reputation: 0
Posts: 8
Joined: Mon Oct 01, 2007 6:05 pm
Highscores: 0
Arcade winning challenges: 0
^ Back to Top