Copy link to clipboard
Copied
This is an embarrassingly rookie question, but I want to know how to use Javascript in Captivate so that it also works with Flash output.
Let me tell you what I am doing, which works with HTML output:
Result - When I preview this in HTML5, you can click the click box and watch the value of the variable increment. When I preview in Flash, the value remains 0 when I click the click box.
How do I get this to work in Flash?
Copy link to clipboard
Copied
That is not JS, but advanced actions, or do I misunderstand?
This should work perfectly, it is such a simple action. And SWF output has a much longer history than the new HTML5.. Can you post a screenshot of the advanced action?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
In HTML, you see the value increment. In Flash, this doesn't work.
Copy link to clipboard
Copied
As you see, I simplified it some more, but I still have the same problem that it doesn't work like I want it to in Flash.
Copy link to clipboard
Copied
So it is JS, not an advanced action. How did you test? You have to deploy also the Flash version in a browser, which means you have to publish it.
Copy link to clipboard
Copied
Yes, I published once as HTML and once as Flash. Here are my Flash settings. Maybe it is an issue with my browser?
Copy link to clipboard
Copied
here is a video of my attempts...
Copy link to clipboard
Copied
I only did see a Preview in your video. You have to publish for SWF output.
Copy link to clipboard
Copied
and when I publish it..
https://drive.google.com/file/d/0B1VqJFseatNrakNzVmswZXRaQlk/view?usp=drivesdk
Copy link to clipboard
Copied
Here is a video of me publishing it.
Copy link to clipboard
Copied
Looks like a Flash Global Security issue/
http://www.infosemantics.com.au/adobe-captivate-troubleshooting/how-to-set-up-flash-global-security
Copy link to clipboard
Copied
Hi RodWard,
Unfortunately, that didn't work.
That was great info about the Flash Security Settings. Up until now, I didn't have any "trustworthy" files or folders according to the settings. Now a folder on my desktop is "trustworthy". I published my .swf project to this folder, but like I said before, I have the same problem. I changed the settings on my Windows operating system, not the "online" settings. I had trouble adding a folder there; my operating system insisted that I add a file...
Because of your article I thought of another way to test to see if it there is a Flash Security issue on my PC. I published the project as Flash and uploaded the zip file to scormcloud.com, so that the project is hosted on scormcloud. I found out that it does not work there either. I assume this rules out any Flash Security settings problem...
Thanks for the help! If you have any other ideas, I am all ears.
Ryan
Copy link to clipboard
Copied
Check your JavaScript coding again.
What is the exact code that you are trying to execute? If it's the code you posted earlier (NumberOfClicks++) that's not a valid JS script.
Copy link to clipboard
Copied
Hi RodWard,
Yes, you are correct. That was my "Javascript".
I guess I don't understand how Captivate and JS work together. If I were using the DOM API, I would write something like:
var numberOfClicks = 0;
function incrementClicks(){numberOfClicks++};
var clickBox = document.getElementById('clickBox');
clickBox.addEventListener("click",incrementClicks);
I am playing around with JS in Captivate for the first time, so I wanted to started as simple as possible. I figured because I already defined the variable in Captivate, I didn't have to do it again. And I don't have to add an event listener to the click box because I assumed it came with one.
But my real problem is that my one line of code works in HTML5.
This also works in HTML5.
numberOfClicks++;
alert("you clicked!");
The inconsistent feedback makes it difficult to test the JS.
Copy link to clipboard
Copied
If you want the JS to work, you need to wrap it in Functions and then you need to call that function.
Copy link to clipboard
Copied
Now my JS looks like this:
function iterate () {numberOfClicks++;}
iterate();
Works in HTML but not Flash.
Copy link to clipboard
Copied
I also tried inserting the first line of code function iterate () {numberOfClicks++;} at the beginning of the standard.js file post-publishing and having the click box trigger the script iterate().
Copy link to clipboard
Copied
I tried two other things to no avail...
Uploaded the project to scormcloud.com with the function in Captivate and uploaded the project to scormcloud.com with the function manually placed at the front of standard.js after publishing.
So in the first attempt, this was the JS in Captivate.
function iterate () {numberOfClicks++;}
iterate();
In the second attempt, this was the JS in Captivate: iterate(); with function iterate () {numberOfClicks++;} placed at the front of standard.js.
Copy link to clipboard
Copied
Hi RodWard,
It has to do something with my computer. I just downloaded and published the "WeatherData" Adobe Captivate project. (Sample project here Common JS interface)
I have the same issue - the published HTML5 works, but the published Flash doesn't. I am using IE to test both. And the folder is trusted per Flash settings.