Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


Make an image a hyperlink



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> Flash Forum
View previous topic :: View next topic  
Author Message
anyonewannaspud



Joined: 01 Oct 2007
Posts: 8

PostPosted: Sat Apr 05, 2008 4:37 pm    Post subject: Make an image a hyperlink Reply with quote

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 Smile
Back to top
View user's profile Send private message
webmaster
Site Admin


Joined: 17 Aug 2004
Posts: 3593
Location: Sweden

PostPosted: Sun Apr 06, 2008 10:28 am    Post subject: Re: Make an image a hyperlink Reply with quote

You'll have to change the XML code to send a link for every photo too, like this:
Code:
<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.
Back to top
View user's profile Send private message Visit poster's website
anyonewannaspud



Joined: 01 Oct 2007
Posts: 8

PostPosted: Sun Apr 06, 2008 10:38 am    Post subject: Re: Make an image a hyperlink Reply with quote

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:
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:
//trace (itemlist.length);
//trace (itemlist[0]["thumb"]);
this.createEmptyMovieClip("strip", this.getNextHighestDepth());
var i = 0;
var w = 0;




Next Keyframe

Code:
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:
if (this.strip["photo"+i].getBytesLoaded() != this.strip["photo"+i].getBytesTotal()) {
   gotoAndPlay(_currentframe-1);
}





Next Keyframe:

Code:
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:
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 Smile

cheers!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> Flash Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap