Articulate Storyline and Actionscript

Jul 14, 2014

Hi folks,

I hope that someone could help me with my query. I have embedded a swf file using Flash AS3 into Storyline.

However, I would like a "next" button on the final Flash slide of the swf file link to next Storyline slide.

Is this achievable? Also does Storyline only work with AS3? - Screenshot below

Thanks again

Andrew

15 Replies
Alexandros Anoyatis

Hi Andrew,

Using Actionscript on the source .fla, you would have to find a way to manipulate the final Flash slide to somehow change an already defined Storyline variable value upon clicking the button (I assume that button is placed inside the SWF?) and then create a listener trigger within storyline in the form of "Go to next slide when variable changes".

I cannot help you with any code though as I'm not that well versed in ActionScript.

Alex

Steve Flowers

I'd use an ExternalInterface call to directly modify a variable in JavaScript and use a variable listener trigger as Alex recommends.

To modify a variable in SL through the JS API:

var player=GetPlayer();

player.SetVar("SLVariable", yourValue);

Would be great to be able to set things directly through AS. It's not really that simple:(

Steve Flowers

Hey Andrew - there's a lot going on to illustrate two way communication with multiple events. For one way communication, it's pretty simple. In the example below, I'm assuming that the value coming in from GetVar will be a valid integer.

On your Flash button:

_button.addEventListener(MouseEvent.CLICK, buttonClickHandler);

function buttonClickHandler(event:MouseEvent):void{

//grab the current value from Storyline and increase it by one

var valueIn:int=ExternalInterface.call('GetPlayer().GetVar','yourStorylineVariable');

valueIn++;

//send a new value to Storyline

ExternalInterface.call('GetPlayer().SetVar','yourStorylineVariable',valueIn);

}

In Storyline:

When variable yourStorylineVariable changes, jump to next slide.

Alan Baertschi

Steve, I'm hoping you can help me with a simple button within a .swf file that will trigger for Storyline to advance the next slide, like the original post asked.

I used your AS3 code:

nextSlideBtn.addEventListener(MouseEvent.CLICK, nextSlideHandler);

function nextSlideHandler(event:MouseEvent):void{

//grab the current value from Storyline and increase it by one

var valueIn:int=ExternalInterface.call('GetPlayer().GetVar','storylineNextSlideVariable');

valueIn++;

//send a new value to Storyline

ExternalInterface.call('GetPlayer().SetVar','storylineNextSlideVariable',valueIn);

}

Now, in Storyline I created this variable:
Name: storylineNextSlideVariable
Type: Number
Value: 0
and this Trigger:
Action: Jump to slide
Slide: next slide
When: Variable changes
Variable: storylineNextSlideVariable
Any thoughts would be very much appreciated!
Pierre Jouan

Thanks Steve for your answer !

I just needed to pass a variable to my SWF from Storyline.

Now I have a little problem : my SWF needs a variable from SL before it starts so it can jump to a particular section according to the value of this variable.

But the trigger "When timeline starts" actually sets the variable when everything is set on stage so it's actually available for the next slide !

Is there a clean way to set a variable before everything else in SL ?

I could of course set the variable at the end of the previous slide but that's not very clean, especially if slides are swapped...

I could also make the SWF start afterwards but I would get an ugly flash (!) at the beginning of the slide.

Any idea ? Thanks.

Alan Baertschi

This is in response to Andrew's original post about creating a button in a SWF to trigger Storyline to advance the next slide. I finally got it figured out. Here it is. Hope this will help someone out there in the internets.

___________ AS3 (ActionScript 3.0)___________________

play();

//----------Flash Buttons to Control Storyline Navigation---------------
nextSlideBtn.addEventListener(MouseEvent.CLICK, nextSlideStoryline);
prevSlideBtn.addEventListener(MouseEvent.CLICK, prevSlideStoryline);

function nextSlideStoryline(evt:MouseEvent):void {
ExternalInterface.call("FlashNaviListener", "nextSlide");
}

function prevSlideStoryline(evt:MouseEvent):void {
ExternalInterface.call("FlashNaviListener", "prevSlide");
}

___________Storyline Variable___________________

navigationControl
- Text

___________Storyline Trigger (Next Slide)___________________

Action: Jump to slide
Slide: next slide
When: Variable changes
Object: navigationControl
On Condition: navigationControl == Equal to (ignore case) nextSlide

___________Storyline Trigger (Previous Slide)___________________

Action: Jump to slide
Slide: previous slide
When: Variable changes
Object: navigationControl
On Condition: navigationControl == Equal to (ignore case) prevSlide

___________Storyline Trigger (JavaScript)___________________

Action: Execute JavaScript
Script:

var player = GetPlayer();

FlashNaviListener = function(param){
player.SetVar("navigationControl",param);
player.SetVar("navigationControl",null);
}

When: Timeline starts

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