Copy link to clipboard
Copied
I have successfully displayed the progress using a % value, but when I added videos that extended the duration of two slides, the percentage value went from a nice integer value to a very long decimal value. This displays only after publishing to HTML5 and viewing on the web server (it doesn't show up when previewing in Cap7).
Preview:
After Publishing:
I created a variable for the percentage set to 1, then executed an advanced action that generates the percentage.
How can I also limit the numeric display to an integer with no decimal values?
Thanks in advance!
Kymm
Copy link to clipboard
Copied
Captivate doesn't currently have a built-in number rounding function. I've seen people say they had to use JavaScript to do this.
Copy link to clipboard
Copied
There are no functions in advanced actions, and that is why you have to use Javascript to truncate the result that you get in the variable v_percent.
Have a look at the website of Jim Leichliter and his excellent recent video series about JavaScript: http://captivatedev.com/2014/01/02/javascript-video-series-adobe-captivate-7/
Copy link to clipboard
Copied
Thanks for this resource, Lilybiri! I'll probably get the course and start diving into JS a little.
In the meantime (to solve for this project ASAP), would you or some other kind soul be able to whip up the js script? I'm stuck.
With my lack of js knowledge, I'm guessing that the calculations on the percent value would occur in the js script, while the Advanced action would still handle setting the variable to be calculated. Just a guess. Ideas?
Thanks!
Copy link to clipboard
Copied
I am still a newbie myself, working through that course that I recommend warmly. And I already know that the JS API is different for HTML5 and for SWF output. Which output do you need?
Copy link to clipboard
Copied
I haven't used it, but CP Guru seems to have a widget that might help you. However, it works only in SWF outputs.
http://www.cpguru.com/rounding-widget-for-adobe-captivate/
Sreekanth
Copy link to clipboard
Copied
We're publishing to HTML5.
Copy link to clipboard
Copied
You might try this. Use 2 variables to display the text, one with the math and the other with the %.
$$var_1$$$$var_2$$
After you publish, open the CPM.js file and look for a line like this:
cp.cv('yourVariableName',,0,15);
Change the 15 to a 2. This is the length of the variable.
Might work in a pinch
Copy link to clipboard
Copied
You can change the number of digits also when inserting the variable. But... it will not be rounded, it will be truncated. I don't think that is the goal.
Will try tomorrow to post a script, after I have tried it out myself. Bit too late here in Belgium.
Copy link to clipboard
Copied
Rounded would work for me when publishing to HTML5. I have the buttons set to activate the advanced actions, I'm just not sure how these javascripts are put into progress to "attach" to the figures which are calculated from the advanced actions/variables.
I know how to attach a JS. But not sure how the JS can latch onto the Advanced Action.
Copy link to clipboard
Copied
Why not use the command Execute Javascript in the Advanced Actions dialog box, after the calculation statements? You'll have to copy the script to the script window, it will not be in an external JS file.
Copy link to clipboard
Copied
OK, I think I discovered my problem. I didn't attach the JS too ALL the slides, just the final tallied slide. Once I entered the JS (for the page) on each of the slides with data - the tallied amount was limited to the two decimals. Works like a champ.
For anyone interested, I used the JavaScript from this page:
Copy link to clipboard
Copied
I stand corrected. Still not working, with apologies.
Copy link to clipboard
Copied
Lieve -
I played around with this a bit and discovered that if I changed the "Maximum Width" of the variable of "50" to "5" (which includes the decimal point), that really is all I need. Sure, it's not going to round off the figure or anything - but to be honest, it works for me.
Amazing how much you pick up after playing with this stuff. Normally I haven't had the need to mess around with the Advanced Actions and whatnot, but have found myself having to do that more and more. And I'm liking it. God help me. I really am.
Kevin
Copy link to clipboard
Copied
It is truncating, if that is fine, OK.
Advanced actions are addictive. I know about that addiction.