How can I grab a current image state and save it in a user variable?
I am looking for a way to grab the current image state and save it as a user variable for referencing later in a project. I am looking to grab a user’s state selection and then reveal different images later in the project. Any insight you could provide would be helpful.
You got a JS answer indeed. But did you ever check this blog post where I use rather easy advanced actions to change states in other slides?
http://blog.lilybiri.com/choose-and-use-personal-avatars
Greg, you need to publish that book, or at least a user cheat sheet with all of these great options. This is exactly what I needed. How are you figuring out all of these powerful calls. I am transforming and simplifying the use of advanced actions with Javascript. It’s so much faster and easier to do. Do you have a current list somewhere with the basic actions? I want to play an audio file that I’ve imported and used in my project triggering it with javascript. would cp.playAudio(“name of audio”) work? I need to get hold of a set of these captivate calls so I can implement them in my project.
Works like a charm and powerful in conditional actions.
Many of the new ones I learned through studying the console.
Launch a project preview and open the console.
Start typing cp.
…then see all the commands that appear!
At that point – it is much trial and error to figure out the parameters to make them work.
Audio is tough to work with because Captivate changes the name of your uploaded audio file to some random number.
My approach has been to tie playing audio to a discrete “hidden” click box on the screen somewhere. Then I use JavaScript to perform the click on that box when I need it.
I saw your comments about that on another post. So, rather than playing the audio you initiate the click box to start the audio. Not as intuitive. I was hoping to trigger a variety of audio files from an array. So the effect is different each time the trigger occurs. I’m gonna have to give this a try.
Hi Michael,
there’s a way with javascript. All states of an object in Captivate are listed in an Array. This is a kind of listing of all states (items). Each item has an index number depending on the position in the (states)-Array.
Assuming your user variable to store the current image state index is called myImageCurrentStateIndex and the image object is called myImageObject then you can grab the current state with
myImageCurrentStateIndex = cp.model.data.myImageObject.currentState;
This is all related to the data stored in the CPM.js which accompanies each published Captivate HTML5 project. However, what you get as myImageCurrentStateIndex is the index number (position) within that particular myImageObject (states)-Array. Be aware that Array index numbers start counting with 0 (zero).
Now you could create another variable (Array as well) to store your state names of myImageObject. Like i.e.
myImageObjectStateNames = [“Normal”, “red”, “blue”, “green”, “purple”];
So if the grab via cp.model.data returns for instance 2 then you can get the particular state name by scripting
myImageCurrentStateName = myImageObjectStateNames[myImageCurrentStateIndex];
This would return the state name “blue”.
Hope this helps
Klaus
You must be logged in to post a comment.