开发者

How do modify image data in SlidesShowPro using Flash ActionScript3

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

function on开发者_开发问答SlideShowClick(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?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜