views:

24

answers:

2

I'm using SlideShowPro with Flash AS3 and I have the following code:

function onSlideShowClick(event:SSPImageEvent) {
  if (event.type == "imageClick") {
    // modify the link for when the image is clicked.
  }
}

How can I modify the link for when the image is clicked? Can that be done here? Elsewhere?

+1  A: 

You could try giving something like this a whirl...

var currentLink:String = "";

function onSlideShowData(event:SSPDataEvent) {
  currentLink = event.link;
}
my_ssp.addEventListener(SSPDataEvent.IMAGE_DATA, onSlideShowData);

function onSlideShowClick(event:SSPImageEvent) {
  if (event.type == "imageClick") {

    // Alter the image link
    currentLink = currentLink + "?someparam=somevalue";

    // Send the user to the altered url.
    flash.net.navigateToURL(currentLink);
  }
}
my_ssp.addEventListener(SSPImageEvent.IMAGE_CLICK, onSlideShowClick);

It basically stores the current link (assuming you defined one in the xml) to a variable whenever the image changes. Then when you click an image it just uses the standard navigateToUrl() method.

Now, I have some doubts that this will work because you aren't able to cancel the SSPImageEvent from within the handler function, and therefore I think that SSP will just fire the navigateToURL() function on whatever was defined in the xml immediately after your handler executes. But give it a try.

jessegavin
I'm looking for a way to programmatically alter the target URLs.
jwhat
I just updated my answer. It should theoretically allow you to do that, though I am not sure if it will work.
jessegavin
Thanks jessegavin, your example told me that I should look at onSlideShowData instead of onSlideShowClick.
jwhat
A: 

I ended up figuring it out with some help from the API docs.

public function onSlideShowData(event:SSPDataEvent):void {
  if (event.type == "imageData") {
    // Modify the image link.
    event.data.link = "http://somedomain.com/?url=" + escape(event.data.link);
  }
}
my_ssp.addEventListener(SSPDataEvent.IMAGE_DATA, onSlideShowData);

Reference API docs: http://wiki.slideshowpro.net/SSPfl/API-AS3Event-imageData

jwhat
Very cool, glad you found your solution
jessegavin