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.
Had a look at the zip file you attached. To be honest, I do not know where to start in order to decipher the code and to implement this to the problem that faces me. Thanks again though. Will have another look at some point.
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.
why not cover the button with a transparent button from storyline and set it to advance to the next slide will give the appearance of using the button and will function with storyline.
A simpler suggestion That would work perfectly except for any feedback desired on the button. Though the AS3 to JS isn't all that complicated and works pretty reliably.
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 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.
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.
//----------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"); }
15 Replies
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
Thanks Alex for your response. I will investigate this issue further and let the other members know of my findings.
Thanks again
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:(
This might be helpful. Haven't opened it in awhile.
https://dl.dropboxusercontent.com/u/19820702/flashStoryline.zip
Thanks Steve for your quick responses. I will let you know how I get on.
Hi Steve,
Had a look at the zip file you attached. To be honest, I do not know where to start in order to decipher the code and to implement this to the problem that faces me. Thanks again though. Will have another look at some point.
Andrew
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.
why not cover the button with a transparent button from storyline and set it to advance to the next slide will give the appearance of using the button and will function with storyline.
A simpler suggestion
That would work perfectly except for any feedback desired on the button. Though the AS3 to JS isn't all that complicated and works pretty reliably.
Thanks gents for your speedy responses. Will have a look at this tomorrow.
Thanks again.
hi folks,
I have attached the zipped up flash file. Any help would be appreciated.
Thanks again for your support.
Andrew
oops and the others....sorry
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);
}
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.
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.