7 Replies Latest reply on Jun 11, 2018 7:47 AM by bobbyjourdan

    Javascript in captivate

    craigs8411935 Level 1

      Hi all

       

      I am using this code

       

           var box = $('#restart_loop')[0]; cp.clickHandler(box);

       

      on an "on Enter" action for a slide in my captivate, it initiates an advanced action on a hidden button on the slide.

      this works perfectly, but I want to add a .oam object that I have built in adobe animate cc with a button that can also initiate the same function

      i would normally use:

       

           this.Reset.addEventListener("mousedown", fl_MouseClickHandler.bind(this));

           function fl_MouseClickHandler()

           {

            window.parent.cpAPIInterface

           )

       

      to control captivate from an animate object. so I tried:

       

           this.Reset.addEventListener("mousedown", fl_MouseClickHandler.bind(this));

           function fl_MouseClickHandler()

           {

           var box = $('#restart_loop')[0]; cp.clickHandler(box);

           }

       

      this did nothing so what I am wondering is how would I combine:

       

           var box = $('#restart_loop')[0]; cp.clickHandler(box);

       

      with:

       

           this.Reset.addEventListener("mousedown", fl_MouseClickHandler.bind(this));

           function fl_MouseClickHandler()

           {

           window.parent.cpAPIInterface

            }

        • 1. Re: Javascript in captivate
          ClayUUID Adobe Community Professional

          This is the Adobe Animate forum. You want the Captivate forum.

          • 2. Re: Javascript in captivate
            Colin Holgate MVP & Adobe Community Professional

            I think here is an ok place to ask this, seeing as the solution goes into your Animate code.

             

            I don't really know JQuery at all, but it also seems to have a .parent() function. Would this work?:

             

            with:

             

                 this.Reset.addEventListener("mousedown", fl_MouseClickHandler.bind(this));

                 function fl_MouseClickHandler()

                 {

                 var box = $(window.parent().'#restart_loop')[0];

                 window.parent.cpAPIInterface(box)

                  }

            1 person found this helpful
            • 3. Re: Javascript in captivate
              craigs8411935 Level 1

              Well I'm asking how I make my javascript code in Adobe animate access this particular var in captivate, most of the interaction stuff that I use in animate cc to control adobe captivate variables and bits I find in this forum not the adobe captivate forum, mainly because the interactions I create are not standard out of the box stuff that captivate does, I only really use captivate ad a wrapper for animate.oam files to produce unique e-learning interactions.

              • 4. Re: Javascript in captivate
                craigs8411935 Level 1

                Hi Colin, thanks will give it a go and let you know

                Kind regards

                Craig Sumner

                • 5. Re: Javascript in captivate
                  craigs8411935 Level 1

                  Hi Colin

                   

                  that just broke the oam. the preview and the oam both could not display the button after I applied the code in animate cc,

                  I tried a few variations such as window.parent.cp but none of it had any effect

                  • 6. Re: Javascript in captivate
                    Colin Holgate MVP & Adobe Community Professional

                    You could look in the browser's developer tools to see if there are any errors that would give a clue about what's going wrong.

                     

                    Would you be able to post the page somewhere we can try it?

                    2 people found this helpful
                    • 7. Re: Javascript in captivate
                      bobbyjourdan Level 1

                      Hi Colin

                      I have been reading the post and also other similar ones but I cannot find the way to control Captivate from the Animate oam movie.

                      What would be the simplest command that I can attach to a button in Animate project that would be exported to oam.

                      In Captivate I would use this JS line to move to the next slide for instance.

                       

                       

                      window.cpAPIInterface.next();
                      

                       

                      How can I attach it to a button in Animate. I try this for instance but without success...

                       

                      this.Reset.addEventListener("mousedown", fl_MouseClickHandler.bind(this));      
                      function fl_MouseClickHandler()      
                      {      
                      window.cpAPIInterface.next();      
                      }