It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Partner Sites
Board index Programming Flash Forum

Make an image a hyperlink

Moderator: Phate

Make an image a hyperlink

Postby anyonewannaspud on 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
 
Posts: 8
Joined: Mon Oct 01, 2007 6:05 pm

Postby webmaster on 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.
User avatar
webmaster
Site Admin
 
Posts: 2557
Joined: Tue Aug 17, 2004 2:07 pm
Location: Sweden

Postby anyonewannaspud on 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
 
Posts: 8
Joined: Mon Oct 01, 2007 6:05 pm


Return to Flash Forum

Who is online

Users browsing this forum: No registered users and 0 guests