On Launch, Opening at any location in a Story

Jul 12, 2014

I recently ran into a problem and was able to cobble together a solution based on the excellent help found here, so I thought I would share what I discovered.

Now it is possible that there is a much simpler solution, but I couldn't find it, so this is what we came up with:

The problem was with a set of questions I had in one Storyline but with the explanations in several other already existing stories. If a person got the question wrong I wanted to direct them to the applicable other Story, and directly to the slide or scene with the applicable explanation. I could have put the slides into the storyline with the question, but for several reasons this was not desirable, the main one being the size of the combined story.

We reasoned that directing the user to the exact slide should be doable with url parameters. That is how we came across this extremely useful thread with code:

http://community.articulate.com/forums/p/33663/246001.aspx

The excellent applicable code in that thread was added by David Richmond and it allows a storyline to process url parameters into storyline variables. This is my modified version of that code (not very modified at all):

function gup( name )

{

name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");

var regexS = "[\\?&]"+name+"=([^]*)";

var regex = new RegExp( regexS );

var results = regex.exec( window.location.href );

if( results == null )

return "";

else

return results[1];

}

var player = GetPlayer();

var startpage = gup("startpage");

if(startpage != ""){player.SetVar("StartPage",startpage)}

The text variable StartPage was created to handle the situation. A text variable was used instead of a number so that the vectoring could be named with something logical. With many scenes in the target story, StartPage=1 could refer to many different pages. The variable has the default value of the page the story should go to should no page identification be passed to the story.

But then, how to use that variable information to immediately go to the specified page?

The solution was to create one trigger for each possible landing location. Each trigger is set to run when the launch page timeline starts and each one directs that the story jump to the applicable page IF the StartPage variable is equal to a certain value (e.g. "Two").

These links show how it works. The first has no url string attached and goes to the default page.

http://www.chronodex.com/articulate/pagestarttest/story.html

This goes to page 2.

http://www.chronodex.com/articulate/pagestarttest/story.html?startpage=Two

Change the specified page to "two". You will notice that it doesn't work. Unlike regular url parameters, this setup is case sensitive. With a little additional coding, it could be made case-insensitive.

startpage=Three will also work.

Be the first to reply

This discussion is closed. You can start a new discussion or contact Articulate Support.