CaptivateController Updated to Support Setting Variable Values

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!");

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

New SCORM ebook coming soon!

I'm writing an ebook explaining how to build an HTML-based SCORM course. Subscribe to be notified when it's ready, as well as receive early bird pricing and some free goodies!

No spam, no sharing your email address, unsubscribe at any time. Powered by ConvertKit
Advertisements

13 Replies to “CaptivateController Updated to Support Setting Variable Values”

  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.