slideplayer.api.IHyperlinksManager Interface

The IHyperlinksManager Interface provides slides with an ability to switch to another slides or open external web pages. A standalone slide does not switch to another slide when a hyperlink is clicked. An external Flash application can use setHyperlinksManager() method of the ISlideController interface to pass an object implementing the IHyperlinksManager interface which receive notifications when user clicks a hyperlink or action button.

The following methods are exposed by the IHyperlinksManager interface.

Table 1. Methods
Method Description
gotoSlide(slideIndex:Number):Void This method is invoked when user clicks a hyperlink to another slide An implementation can hide the current slide and load and show the new one
openURL(url:String, target:String):Void This method is invoked when user clicks a hyperlink to an external web page or other resource Note: the simplest way to implement this method is to call following ActionScript function: getURL(url, target)
gotoLastViewedSlide():Void This method is invoked when user clicks a hyperlink to the last viewed slide. An implementation must hide the current slide and show the slide that was shown before
endShow():Void This method is invoked when user clicks a hyperlink that finishes slide show Typically, an implementation unloads all slides of the current presentation

Samples

The following example illustrates a typical IHyperlinksManager interface implementation and shows its usage.

CMyHyperlinksManager.as

import slideplayer.api.*;

class CMyHyperlinksManager implements IHyperlinksManager
{
    private var m_viewedSlides:Array;
    private var m_currentSlideIndex:Number;

    function CMyHyperlinksManager()
    {
        m_viewedSlides = new Array();
    }

    function gotoSlide(slideIndex:Number):Void
    {
        m_currentSlideIndex = slideIndex;
        m_viewedSlides.push(slideIndex);
        loadSlide(slideIndex);
    }

    function loadSlide(slideIndex:Number):Void
    {
        // empty
    }

    function openURL(url:String, target:String):Void
    {
        getURL(url, "_blank");
    }

    function gotoLastViewedSlide():Void
    {
        if (m_viewedSlides.length > 1)
        {
            var curSlide:Number = Number(m_viewedSlides.pop());
            var lastViewedSlide:Number;

            do
            {
                lastViewedSlide = Number(m_viewedSlides.pop());
            } while ((lastViewedSlide == curSlide) && (m_viewedSlides.length != 0));

            if (lastViewedSlide != curSlide)
            {
                gotoSlide(lastViewedSlide);
            }
            else
            {
                m_viewedSlides.push(curSlide);
            }
        }
    }

    function endShow():Void
    {
        fscommand("quit", "true");
    }
}
    

CMyHyperlinksManager class usage example:

import slideplayer.api.*;
System.security.allowDomain("*");

var rootMC:MovieClip = this;
var slidesMC:MovieClip = rootMC.createEmptyMovieClip("slidesMC", 2);
var slideMC1:MovieClip = slidesMC.createEmptyMovieClip("slide1", 1);

var g_slideController:ISlideController;
var g_hyperlinksManager:CMyHyperlinksManager = new CMyHyperlinksManager();

g_hyperlinksManager.loadSlide = function(slideIndex:Number):Void
{
    loadSlide(slideIndex);
}

g_hyperlinksManager.gotoSlide(0);

// loads slide with the specified slide index
function loadSlide(slideIndex:Number):Void
{
    // remove hyperlinks manager from the current slide
    g_slideController.setHyperlinksManager(undefined);

    var ml:MovieClipLoader = new MovieClipLoader();
    ml.addListener(this);
    ml.loadClip("data_hl/slide" + (slideIndex + 1) + ".swf", slideMC1);
}

function onLoadInit(target:MovieClip):Void
{
    g_slideController = target.getSlideController();

    slideController.setHyperlinksManager(g_hyperlinksManager);
}
    

Demo

The following demo illustrates hyperlinks and action buttons handling via IHyperlinksManager interface.