The title says it all.

The pipwerks CaptivateController now includes a set method that enables developers to set a Captivate variable’s value using JavaScript.

var myMovie = CaptivateController("Captivate");
myMovie.set("myCustomCaptivateVariable", "Hello!");Code language: JavaScript (javascript)

Give the new set method a spin!
Read about the CaptivateController here.
Download the CaptivateController here.


Comments

Ouija wrote on November 7, 2011 at 3:12 pm:

This is the greatest script ever created!! Kudos to you for a job well done!

I wanted to mention that I was using this for a presentation of mine, and had debugging enabled in my Flash Player and was getting a number of errors popping up when using your script to grab variables on a submit button.

Not a huge deal, as this is what debug mode is for and with it off the script works fine, but just wanted to mention that it was throwing up some errors 🙂

philip wrote on November 7, 2011 at 4:12 pm:

I'm not surprised to hear of warnings or the occasional non-fatal error, they are side effects of many of the hoops required to get to the Captivate SWF via JavaScript. If you find any errors, please post them to the <a href="https://github.com/pipwerks/CaptivateController/issues" rel="nofollow ugc">issues list</a> on GitHub so I can take a look. Thanks!

Andrew Minton wrote on November 16, 2011 at 12:27 am:

Using CP 4 and using the exact setup for set variables from JS to CP and I get no text box populated with the var… has anyone else encountered this?

philip wrote on November 16, 2011 at 9:08 am:

@andrew I must admit I didn't test the new 'set' feature on CP4 projects, I only have CP5+. I'll see if I can dig up my old CP4 disc.

ouija wrote on November 28, 2011 at 11:22 pm:

I am having some issues getting gotoSlideAndPlay to work with my project; I think it *might* have something to do with the swjobject embedding code I am using but am uncertain; Bascially I am trying to use your controller in a function:

function gotoAndPlay(slide){
//Establish CaptivateController
var myMovie = CaptivateController("Captivate");

//Set value of userName variable inside Captivate SWF
myMovie.gotoSlideAndPlay(slide);
}

and have the swfembed code like follows:
swfobject.embedSWF("quiz.swf", "Captivate", "640", "480", "10", "", "", bgcolor);

(and also have a bgcolor function to set the swf background color if I prefer)

But for some reason, when I try and use the gotoAndPlay(3); function nothing happens…. I'm sure it's something I am doing since I am a fool when it comes to javascript, so any help you can provide to point me in the right direction is greatly appreciated!

Thanks

philip wrote on November 28, 2011 at 11:40 pm:

@ouija i'm not sure what the issue is, but i do know your SWFObject code is malformed. The bgcolor should be a property of the <code>params</code> object and cannot be a string.

<pre>
swfobject.embedSWF(“quiz.swf”, “Captivate”, “640″, “480″, “10″, “”, “”, bgcolor);
</pre>

Should probably be
<pre>
var flashvars = false,
params = { bgcolor: "#FF3366" },
attributes = false;
swfobject.embedSWF(“quiz.swf”, “Captivate”, “640″, “480″, “10″, flashvars, params, attributes);
</pre>

Remember also that <code>gotoAndPlay</code> uses a zero-based index. Saying <code>gotoAndPlay(3)</code> actually means to go to Slide 4. Do you have a 4th slide?

Update: I forgot that I modified my code to accept non-zero-based indexes, so ignore my comment about zero-based index.

ouija wrote on November 29, 2011 at 12:33 am:

Yeah, I actually changed that using the code I found in your example to embed your swf, figured it was wrong 🙂

And managed to figure out my issue with the controller, so all is well! Thanks again for such an awesome utility! Makes my life so much easier!

ouija wrote on November 29, 2011 at 1:23 am:

Sorry for all the comments, feel free to delete if you like, but it actually won't go past the third slide at all… tried deleting them and just using normal slides and it doesn't work.. I can't seem to figure out what the issue is… the first 3 slides work but the remaining don't… I'll keep trying different things to figure out what the issue might be..

ouija wrote on November 29, 2011 at 1:36 am:

My fouth slide is a fill-in-the-blank… thought that might have something to do with it, but I replaced it with a multiple choice and still having issues… Thought it was Javascript that I was running on Slide entry, but the first 3 slides have the same javascript… Thought maybe it was because the swf wasn't fully loaded (as I am calling the function on my page load) but even with a timer or using an href tag it still won't go past the fourth slide (with the fill in the blank, which is required to have input). However, when you go to the slide normally, enter in something and continue to the next slide, THEN use the href link it will display the slide (but it's really messed up looking)… Will test some more tomorrow but need to get some sleep.

Any help is appreciated!

can't seem to figure out what the issue is.

AJ wrote on December 20, 2011 at 1:14 pm:

I am having a similar issue with gotoSlideAndPlay. It works OK for my first and second slides but nothing past that. When I try to go any further I can a gray background instead of the slide I am expecting. The timeline shows that I am in the correct place but there is not content. I thought maybe it was an issue with the SWF not being fully loaded but I have the pre-loading option in captivate set to 100% and I am working on a local machine so it should load almost instantaneously. Any help you might be able to provide would be great.

philip wrote on December 20, 2011 at 1:31 pm:

@AJ and @ouija

Don't know what to say; CaptivateController is simply using the API made available by Captivate. The behavior you describe sounds like a Captivate bug.

AJ wrote on December 20, 2011 at 2:34 pm:

Thanks for responding. That seems to make sense. Unfortunately the documentation for Captivate is so poor it is hard to find any information that might lead to a work around. In fact most Google searches I have done on Captivate come back with your site in the top 6-10 results. Do you know of any resources that might help one better understand the exposed Captivate API?

It seems that there must be some issue with the skin that I am using. I imagine that the Table of Contents interface also utilizes the same or similar method of changing slides. When I tried turning the TOC on it seemed to work fine for jumping back and fore from slides. In fact they seem to have some code in place to manage persistence. When you reload the page a dialog asks if you want to resume from where you left off. Unfortunately this feature only seems to work when the TOC is on.

On a separate note I came across this article a few months ago and thought it might be useful for you in doing some optimization with your CaptivateController script. http://net.tutsplus.com/tutorials/javascript-ajax/stop-nesting-functions-but-not-all-of-them/ I found the article very insightful.

philip wrote on December 20, 2011 at 3:08 pm:

@aj the API documentation doesn't really exist, I had to scrape the CP ActionScript for clues and do many weeks of testing to see what worked and what didn't. CP also has its own internal logic and rules, so it's quite possible that you can't proceed past your third slide because you've come up against a rule, such as no jumping past quiz slides. Unfortunately these rules are private and have not been publicized by Adobe. You'll have to deconstruct their code to figure it out.

RE: nested functions, I like my style just fine, thank you. (My second comeback is "I just do what Crockford tells me!")

As a commentor and the author <a href="http://net.tutsplus.com/tutorials/javascript-ajax/stop-nesting-functions-but-not-all-of-them/comment-page-1/#comment-383669" rel="nofollow ugc">both stated</a>, prototype is really only helpful (from a performance point of view) if you'll be creating many instances of your object. CaptivateController will rarely have more than a couple.

The CaptivateController source code is on GitHub if you'd like to fork and refactor.

Similar Posts

13 Comments

  1. This is the greatest script ever created!! Kudos to you for a job well done!

    I wanted to mention that I was using this for a presentation of mine, and had debugging enabled in my Flash Player and was getting a number of errors popping up when using your script to grab variables on a submit button.

    Not a huge deal, as this is what debug mode is for and with it off the script works fine, but just wanted to mention that it was throwing up some errors 🙂

  2. I’m not surprised to hear of warnings or the occasional non-fatal error, they are side effects of many of the hoops required to get to the Captivate SWF via JavaScript. If you find any errors, please post them to the issues list on GitHub so I can take a look. Thanks!

    1. @andrew I must admit I didn’t test the new ‘set’ feature on CP4 projects, I only have CP5+. I’ll see if I can dig up my old CP4 disc.

  3. I am having some issues getting gotoSlideAndPlay to work with my project; I think it *might* have something to do with the swjobject embedding code I am using but am uncertain; Bascially I am trying to use your controller in a function:

    function gotoAndPlay(slide){
    //Establish CaptivateController
    var myMovie = CaptivateController(“Captivate”);

    //Set value of userName variable inside Captivate SWF
    myMovie.gotoSlideAndPlay(slide);
    }

    and have the swfembed code like follows:
    swfobject.embedSWF(“quiz.swf”, “Captivate”, “640”, “480”, “10”, “”, “”, bgcolor);

    (and also have a bgcolor function to set the swf background color if I prefer)

    But for some reason, when I try and use the gotoAndPlay(3); function nothing happens…. I’m sure it’s something I am doing since I am a fool when it comes to javascript, so any help you can provide to point me in the right direction is greatly appreciated!

    Thanks

    1. @ouija i’m not sure what the issue is, but i do know your SWFObject code is malformed. The bgcolor should be a property of the params object and cannot be a string.

      swfobject.embedSWF(“quiz.swf”, “Captivate”, “640″, “480″, “10″, “”, “”, bgcolor);
      

      Should probably be

      var flashvars = false,
          params = { bgcolor: "#FF3366" },
          attributes = false;
      swfobject.embedSWF(“quiz.swf”, “Captivate”, “640″, “480″, “10″, flashvars, params, attributes);
      

      Remember also that gotoAndPlay uses a zero-based index. Saying gotoAndPlay(3) actually means to go to Slide 4. Do you have a 4th slide?

      Update: I forgot that I modified my code to accept non-zero-based indexes, so ignore my comment about zero-based index.

  4. Yeah, I actually changed that using the code I found in your example to embed your swf, figured it was wrong 🙂

    And managed to figure out my issue with the controller, so all is well! Thanks again for such an awesome utility! Makes my life so much easier!

  5. Sorry for all the comments, feel free to delete if you like, but it actually won’t go past the third slide at all… tried deleting them and just using normal slides and it doesn’t work.. I can’t seem to figure out what the issue is… the first 3 slides work but the remaining don’t… I’ll keep trying different things to figure out what the issue might be..

  6. My fouth slide is a fill-in-the-blank… thought that might have something to do with it, but I replaced it with a multiple choice and still having issues… Thought it was Javascript that I was running on Slide entry, but the first 3 slides have the same javascript… Thought maybe it was because the swf wasn’t fully loaded (as I am calling the function on my page load) but even with a timer or using an href tag it still won’t go past the fourth slide (with the fill in the blank, which is required to have input). However, when you go to the slide normally, enter in something and continue to the next slide, THEN use the href link it will display the slide (but it’s really messed up looking)… Will test some more tomorrow but need to get some sleep.

    Any help is appreciated!

    can’t seem to figure out what the issue is.

  7. I am having a similar issue with gotoSlideAndPlay. It works OK for my first and second slides but nothing past that. When I try to go any further I can a gray background instead of the slide I am expecting. The timeline shows that I am in the correct place but there is not content. I thought maybe it was an issue with the SWF not being fully loaded but I have the pre-loading option in captivate set to 100% and I am working on a local machine so it should load almost instantaneously. Any help you might be able to provide would be great.

  8. @AJ and @ouija

    Don’t know what to say; CaptivateController is simply using the API made available by Captivate. The behavior you describe sounds like a Captivate bug.

  9. Thanks for responding. That seems to make sense. Unfortunately the documentation for Captivate is so poor it is hard to find any information that might lead to a work around. In fact most Google searches I have done on Captivate come back with your site in the top 6-10 results. Do you know of any resources that might help one better understand the exposed Captivate API?

    It seems that there must be some issue with the skin that I am using. I imagine that the Table of Contents interface also utilizes the same or similar method of changing slides. When I tried turning the TOC on it seemed to work fine for jumping back and fore from slides. In fact they seem to have some code in place to manage persistence. When you reload the page a dialog asks if you want to resume from where you left off. Unfortunately this feature only seems to work when the TOC is on.

    On a separate note I came across this article a few months ago and thought it might be useful for you in doing some optimization with your CaptivateController script. http://net.tutsplus.com/tutorials/javascript-ajax/stop-nesting-functions-but-not-all-of-them/ I found the article very insightful.

  10. @aj the API documentation doesn’t really exist, I had to scrape the CP ActionScript for clues and do many weeks of testing to see what worked and what didn’t. CP also has its own internal logic and rules, so it’s quite possible that you can’t proceed past your third slide because you’ve come up against a rule, such as no jumping past quiz slides. Unfortunately these rules are private and have not been publicized by Adobe. You’ll have to deconstruct their code to figure it out.

    RE: nested functions, I like my style just fine, thank you. (My second comeback is “I just do what Crockford tells me!”)

    As a commentor and the author both stated, prototype is really only helpful (from a performance point of view) if you’ll be creating many instances of your object. CaptivateController will rarely have more than a couple.

    The CaptivateController source code is on GitHub if you’d like to fork and refactor.

Comments are closed.