Question about percentages...

How many people need there to be an option to remove the decimal point in a number? Is it just me? Is there a way to do this that I'm not familiar with?

Currently I have to create a shape like a square with multiple states to get a % that doesn't have a decimal. I have to CREATE every single possibility when making a custom test all because my boss wants a rounded up percent. This means hundreds of triggers added into SL to get two numbers to switch the state of an object to the correct percent. The number correct and the total. This is so much work. I'd love SL to be able to simplify this. I've all ready submitted a feature request a few times on this issue. But if anyone has a suggestion, please let me know.

Jesse

4 Replies
Steve Flowers

Hey, Jesse - 

If you aren't using the iOS player, JavaScript could do that for you in a jiffy.

Here's an example:

Create a JavaScript Trigger. Within this trigger it takes 3 lines to round trip change a variable value to a rounded calculation:

var player=GetPlayer();

var js_myValue=player.GetVar("storylineVariable");

//use this one if you want to round the value to the nearest integer

player.SetVar("storylineVariable",Math.round(js_myValue));

//use this one if you want to round up

player.SetVar("storylineVariable",Math.ceil(js_myValue));

//use this one to round down

player.SetVar("storylineVariable",Math.floor(js_myValue));

So to round a variable called storylineVariable up, you'd use these three lines in your JavaScript trigger:

var player=GetPlayer();

var js_myValue=player.GetVar("storylineVariable");

player.SetVar("storylineVariable",Math.ceil(js_myValue));

  • The first line sets up your player object reference so you can call it using "player". You could just as easily say var george=GetPlayer();
  • The second line grabs your storyline variable using the GetVar function and pushes it into a variable we create. This is a built in player function. There are only two communication functions (for all intents / purposes). 
  • The third line uses the other player function called SetVar to push a value back into the storyline variable. We're pushing in a recalculated version of our created variable, rounding it up and pushing it back in. Fast and easy
Andrew Brooks

Did you ever get a positive response that this had worked...because it didn't for me!

I have two storyline variables:

VarFriends (which takes a numeric input form my slide

VarTotalFriends, which initially contains a value of 0.25, but then via a trigger on a button push, multiplys this by the VarFriends field (in order to give a 25% of the number response.  The response is then posted in a new layer. 

I wanted to produce the integer of the answer, since you couldn't have 4.75% of people!  I tried the JavaScript provided, as follows (with my own variable names inserted), but the answers returned are the same as if the JS isn't running? 

This is sending me round the bend...PLEASE HELP!

The frustration is that I have jumped ship from Captivate, as producing the slides is more long-winded, but Captivate provides more accessible mathematical functions as interactions!

JavaScript:

var js_my_F_Value=player.GetVar("VarTotalFriends");
var player=GetPlayer();
player.SetVar("VarTotalFriends",Math.floor(js_my_F_Value));