Visit SlideShowPro.net  Community Forums
SlideShowPro Support Wiki
  
SWF

Methods and events

Note: As of June 28, 2011, we are no longer selling the SlideShowPro Player SWF product. We will continue to provide support (and this documentation) for those who purchased it prior to the aforementioned date. Click 'email support staff' in the left column if you have any questions or concerns.

SlideShowPro Player SWF has a number of public methods and events that can be accessed outside the SWF via ExternalInterface. This document will explain how to use them.

Turning ExternalInterface off/on

ExternalInterface is a utility through which Flash is able to communicate with Javascript in the web browser. Setting it to "true" allows interactivity like public methods and event listeners (more on those below) to function. ExternalInterface is off by default. To turn it on, add useExternalInterface with a value of "true" to the SWFObject flashvars variable, like so:

var flashvars = {
	useExternalInterface: "true"
}
Note: ExternalInterface can cause security problems if slideshowpro.swf is embedded from a remote site (a domain that's different from where the HTML document is hosted).

Accessing public methods

slideshowpro.swf is setup with ExternalInterface hooks so that any SlideShowPro method can be called through Javascript.

The best way to get a feel for how this works is to open the "js_methods.html" document in the "Examples/Javascript - Methods" folder. In the head you'll notice a series of Javascript methods named the same as the SlideShowPro Player methods to which they relate. They serve as a gateway through which you can call methods inside the SWF and pass parameters, if applicable.

Standalone-only method: getParameter()

Also in the head of the example document you'll see a getParameter() method. This is unique to the standalone version, and allows developers to return the value of any SlideShowPro parameter. The example includes this by popping up the version of the SlideShowPro instance in the SWF in an alert dialogue.

Accessing events

The SlideShowPro Player broadcasts events for changes in playback, gallery data, asset loading, and many more. You can use these to dynamically render captions, titles, or whatever else comes to your imagination.

To see how events work, we recommending viewing the source of the "js_listeners.html" document in the "Examples/Javascript - Listeners" folder. It contains a scrollable DIV element that updates (via Javascript) whenever gallery, album, or image event data is received.

The crux of event listening centers around the Javascript function onSlideShowProReady(). This method is automatically called by slideshowpro.swf when it is available for event listeners to be attached. Attaching events is easy. Here's an example:

function onSlideShowProReady() {
	var ssp = document.getElementById("ssp");
	ssp.addEventListener("albumData","onAlbumData");
	ssp.addEventListener("galleryInfo","onGalleryInfo");
	ssp.addEventListener("imageData","onImageData");
}

Simply assign addEventListener() to the ssp object, then pass in as attributes the name of the SlideShowPro Player event, followed by the receiving method in your Javascript.

For a complete list of all the SlideShowPro Player events you can listen to, click here.

Page last modified by tdominey on September 06, 2010, at 07:43 AM
© 2011 SlideShowPro. All Rights Reserved.