Advent Calendar

Sep 27, 2013

Just curious, as I've never used Java but expect it may be the key, is there any way to put a condition on a button that means it could only be opened on a particular day of the year?  I expect it would need to check the PC's settings somehow.

13 Replies
Steve Gannon

Yes, using JavaScript you can grab the system date and then in Storyline you can compare that date to a value you predefine. If it matches, then you can change the state of your button from hidden (or disabled) to Normal.

You can search the forums for JavaScript examples for getting the date.

Keep in mind that JavaScript only works for published output in Flash and HTML5 formats, not the Articulate Mobile Player/iPad.

Michael Hinze

Hi Gavin, I was just working on a calendar-related project and remembered your post. To get the date into Storyline, I used the following JavaScript:

var JSdate = new Date();
var JSYear = JSdate.getFullYear();
var JSDOM = JSdate.getDate();
var JSMonth = JSdate.getMonth();
var JSDay = JSdate.getDay();
var player = GetPlayer();
player.SetVar("Year",JSYear);
player.SetVar("DOM",JSDOM);
player.SetVar("Month",JSMonth);
player.SetVar("Day",JSDay);

You can then further manipulate the Storyline variables (in my script: Year, DOM, Month, Day)  to create the date format you need. Hope that helps.

Gavin Blagden

Hello I've just used the screenr tutorial and it worked a treat, I'll try yours Michael tomorrow and see if it's the same.  I'm going to have to fiddle with it for english date format and start, I think adding lots of true/false variables for when the dates progress, i.e. if 2/12/13 make 1/12/13 and 2/12/2013 True to reveal.  Thanks for all your advice everyone - this is my first ever attempt at java!

Michael Hinze

Gavin, great to hear that you are making progress! As mentioned, I had just completed a calendar-related interaction for a client. I put a short write-up and a sample on my blog here, in case you are interested to see what's possible with the JavaScript I had listed earlier and a bunch of custom variables, states and triggers.

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