32 Replies Latest reply: Jun 8, 2012 7:45 AM by jeremyaho RSS

    Passing Captivate Variables to Embedded swf's.

    sgovernale

      Does anyone know how to pass a Captivate variable to an embedded swf? I'll elaborate on our situation for more clarity. Ultimately we want to use Captivate to create Scorm packages for use in Moodle. In this particular case, we have a Captivate project in which we have multiple slides. On each slide we want to import a swf that we have created in Flash. Now this Flash swf is set up to parse an external XML file, determine what slide the swf is on and then play the correct video for that slide. This file has a list of video locations (URL) and is organized by slides. The issue we are hung up on is how to pass the Captivate variable (cpInfoCurrentSlide) for the current slide to the embedded swf. Does anyone have any insight?

       

      -S

        • 1. Re: Passing Captivate Variables to Embedded swf's.
          www.cpguru.com Community Member

          Are you using AS2 or AS3 in your project?

           

          If you are using AS2 you simple grab the variable from Captivate through your embedded Flashfile:

           

          var CurrentSlide = _root.cpInfoCurrentSlide

           

          Instead of _root you can also use _parent._parent.

           

          If it's AS3 it would be something like this:

           

          var CurrentSlide = MovieClip(root).cpInfoCurrentSlide;

           

           

          /Michael

           

           


          Visit my Captivate blog with tips & tricks, tutorials and Widgets.

          • 2. Re: Passing Captivate Variables to Embedded swf's.
            sgovernale Community Member

            We are using ActionScript 2.0. I tried your suggestion www.cpguru.com, but I kept getting an 'undefined' value. Here's the code I was using:

             

            var cSlide = _root.cpInfoCurrentSlide;
            if (cSlide){
                 txt_SlideNum.text = "The Current Slide is: "+cSlide+"";
            }

             

            There is a dynamic text box on the stage called "txt_SlideNum" and thats where it was reporting the value "Undefined".

            I also tried the following code but got the same results.

             

            var cSlide = _parent._parent.cpInfoCurrentSlide;
            if (cSlide){
                 txt_SlideNum.text = "The Current Slide is: "+cSlide+"";
            }

             

            Am I doing something wrong?

             

            ___________________________

            |   CAPTIVATE  FILE                    |

            |   _______________________   |

            |   |   Embedded Swf where      |   |

            |   |   ActionScript 2.0 is            |   |

            |   |   located.                            |   |

            |   |______________________|   |

            |__________________________|

             

             

            -S

            • 3. Re: Passing Captivate Variables to Embedded swf's.
              sgovernale Community Member

              I tried the AS 3 version of the code that www.cpguru.com suggested as follows:

               

              var cSlide =  MovieClip(root).cpInfoCurrentSlide;
              if (cSlide){
                  txt_SlideNum.text = "The Current Slide is: "+cSlide+"";
              }

               

              This worked on the first Captivate slide only (sort of). On the first slide, it reported that the slide number was equal to "2". We then duplicated the Captivate slide 3 times and tested it again. We got the same results, "2", on the first slide. Every slide after that was "undefined".

               

              Any thoughts on why this isn't working? Or why the ActionScript 2 version of the code doesn't work at all?

               

              -S

              • 4. Re: Passing Captivate Variables to Embedded swf's.
                www.cpguru.com Community Member

                Sorry my bad.. Must have been tired when I answered your post.

                 

                The cpInfoCurrentSlide is defined within the movie instance. Therefore the correct links for AS2 are:

                 

                _root.movie.cpInfoCurrentSlide;

                 

                _parent._parent.movie.cpInfoCurrentSlide;

                 

                 

                /Michael

                 

                 

                 


                Visit my Captivate blog with tips & tricks, tutorials and Widgets.

                • 5. Re: Passing Captivate Variables to Embedded swf's.
                  sdgovernale

                  /Michael

                   

                  Thanks! That worked perfectly! Thanks for all you help!

                   

                  -S

                  • 6. Re: Passing Captivate Variables to Embedded swf's.
                    sdgovernale Community Member

                    I don't suppose there's a way to pass variables back to Captivate? For example, now that we know current slide number, can we make a button in the embedded swf that will tell captivate to go to the next slide or even just pause the playback of the Captivate slide?

                     

                    Is there some written documentation on how Captivate can communicate with embedded Flash swfs?

                     

                    -S

                    • 7. Re: Passing Captivate Variables to Embedded swf's.
                      www.cpguru.com Community Member

                      Sure you can do that.

                       

                      Here is a list of all the variables:  http://www.cpguru.com/2009/04/28/system-variables-in-captivate-4-%e2%80%93-a-complete-list /

                       

                      I'm not aware of any written documentation, but it's done just as when you grab a variable.

                       

                      Example:

                       

                      _root.rdcmndNextSlide = 1; will send your project to the next page.

                       

                      /Michael

                       


                      Visit my Captivate blog with tips & tricks, tutorials and Widgets.

                      • 8. Re: Passing Captivate Variables to Embedded swf's.
                        sgovernale Community Member

                        /Michael,

                         

                        That is truly exciting news! Thanks for the help! I'm sure others will find the information both helpful and time-saving!

                         

                        Thanks,

                        -S

                        • 9. Re: Passing Captivate Variables to Embedded swf's.
                          geotrice Community Member

                          This is super helpful!

                          • 10. Re: Passing Captivate Variables to Embedded swf's.
                            skyland_mp

                            Hi, Can you give me more info on flash code? I'm trying to pass a custom variable from Captivate to Flash and it is not working. For example, I would like to pass XML file name from Captivate so Flash (AS2) know which xml content to display.

                             

                            Thanks!

                            • 11. Re: Passing Captivate Variables to Embedded swf's.
                              www.cpguru.com Community Member

                              Essentially you grab the variable from Captivate by using a Flash file on that particular slide - or a widget that is present on all slides.

                               

                              Basically if you create a variable in Captivate called v_xmlname then you can get that variable into Flash by creating a Flash file (AS2) and assigning a variable like this:

                               

                              myFlashVariable = _root.v_xmlname;

                               

                              Once this Flash file is executed in your Captivate project then you will have the value of v_xmlname in your Flash variable. Instead of _root you can use _parent. The amount of _parents vary based on if you use playbars etc, but it will work just fine with _root.

                               

                               

                              /Michael


                              Visit my Captivate blog with tips & tricks, tutorials and Widgets.

                              • 12. Re: Passing Captivate Variables to Embedded swf's.
                                ML021469

                                This is probably a flash question but I'll ask with a hopeful heart...

                                Like the previous poster, I have custom variables, UserLName and UserFName, where I capture the user's names.

                                The variables work within the captivate compiled file but, using the code you suggested, I can't seem to get them to display in the embedded .swf..

                                 

                                IBecause I'm a noob at AS2, I'm including all of the AS from the file...the last two lines is where I assign the variables (probably wrong but I tried creating a function based on the other functions to no avial, either):

                                function dateCurrentDay() {
                                    var d:Date = new Date();
                                    d.setDate(d.getDate());

                                 

                                    var dDate = d.getDate();
                                    var dYear = d.getFullYear();
                                    var dMonth = d.getMonth();
                                    var dFullMonth:Array = new Array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12");

                                 

                                    return (dFullMonth[dMonth]+"/"+zeroFill(dDate)+"/"+dYear);
                                }
                                // function to display leading zeros in days
                                function zeroFill(nVal:Number):String {
                                    if (nVal<10) {
                                        return ("0"+String(nVal));
                                    } else {
                                        return String(nVal);
                                    }
                                }//End of zeroFill function that fills in the day with leading zero if less than 10

                                 

                                date_review.text = dateCurrentDay();

                                 

                                function date30DaysFuture() {
                                    var d:Date = new Date();
                                    d.setDate(d.getDate() + 30);

                                 

                                    var dDate = d.getDate();
                                    var dYear = d.getFullYear();
                                    var dMonth = d.getMonth();
                                    var dFullMonth:Array = new Array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12");

                                 

                                    return (dFullMonth[dMonth]+"/"+zeroFill(dDate)+"/"+dYear);
                                }
                                // function to display leading zeros in days
                                function zeroFill(nVal:Number):String {
                                    if (nVal<10) {
                                        return ("0"+String(nVal));
                                    } else {
                                        return String(nVal);
                                    }
                                }//End of zeroFill function that fills in the day with leading zero if less than 10

                                 

                                date_next.text = date30DaysFuture();
                                date_due.text = date30DaysFuture();

                                 

                                FirstName=_root.movie.UserFName;
                                LastName=_root.movie.UserLName;

                                 

                                Any guidance is appreciated...and congrats on the new baby!

                                Michael

                                • 13. Re: Passing Captivate Variables to Embedded swf's.
                                  www.cpguru.com Community Member

                                  Thanks ;o)

                                   

                                  I just glanced through the code and it seems like the path to the variables are wrong.

                                   

                                  You are calling:

                                   

                                  FirstName=_root.movie.UserFName;
                                  LastName=_root.movie.UserLName;

                                   

                                  However, the userdefined variables are not located in the "movie" instance but on the main timeline. Therefore try calling:

                                   

                                  FirstName=_root.UserFName;
                                  LastName=_root.UserLName;

                                   

                                   

                                  You probably also want to add a "var" in infront of the Flash variable or at least declare it in your code somewhere else:

                                   

                                  var FirstName:String;

                                   

                                  or

                                   

                                  var FirstName = _root.userFName;

                                   

                                  It's a bit confusing when to use the movie instance and when not to. I always try without it first and if that fails then I add it and see if it helps ;o)

                                   

                                   

                                  /Michael


                                  Visit my Captivate blog with tips & tricks, tutorials and Widgets.

                                  • 14. Re: Passing Captivate Variables to Embedded swf's.
                                    geotrice Community Member

                                    Your solution for the AS3 code doesn't seem to work in Captivate 5 (mac). Can you offer any suggestions? Are the variables different in CP5?

                                     

                                     

                                    I'm trying to peform the same procedure as before.

                                    Here's my as3 code:

                                     

                                    //Get CP Variables

                                    var currentSlide = MovieClip(root).rdinfoCurrentSlide;

                                    var totalSlides   = MovieClip(root).rdinfoSlideCount;

                                     

                                    //Assign Variables to Dynamic Textboxes

                                    curSlide_txt.text = currentSlide;

                                    totSlide_txt.text = totalSlides;

                                     

                                    I've tried different variations including "MovieClip(parent.parent)" and "MovieClip(parent.parent.movie)" instead of "MovieClip(root)".

                                    I've also tried cpInfoCurrentSlide instead of rdinfoCurrentSlide but according to this: http://help.adobe.com/en_US/captivate/cp/using/WSCB934979-86BE-40d2-8BB8-A66956575988.html the cpInfoCurrentSlide isn't there anymore. I could be wrong.

                                     

                                    I'm really at a loss. Just trying to upgrade because apparently CP5 doesn't support AS2 swfs anymore.

                                    • 15. Re: Passing Captivate Variables to Embedded swf's.
                                      www.cpguru.com Community Member

                                      Hi IGTI,

                                       

                                      I'm not sure that it is possible to access variables etc. in Adobe Captivate 5 the same way as with Captivate 4. I tried earlier this week to access a Captivate variable similar to what you are trying to do and it failed.

                                       

                                      Adobe did change some stuff in regards to which objects etc. are available within Captivate and one of the things is that the slide itself is now a proxy. I think that this could be the reason as to why it's not possible to access variables the same way as in CP4.

                                       

                                      I ended up creating a widget instead to grab the variables I needed.

                                       

                                       

                                      /Michael


                                      Visit my Captivate blog with tips & tricks, tutorials and Widgets.

                                      • 16. Re: Passing Captivate Variables to Embedded swf's.
                                        Maxim K Community Member

                                        I have a similar issue, with the idea to pass internal Captivate variables to an embedded SWF, which would in turn export these variables to SQL. CP Guru mentiones a multiple-score quizz solution in his blog, and what I need is a way to capture these multiple scores in a database.

                                        • 17. Re: Passing Captivate Variables to Embedded swf's.
                                          Fergal Mohan Community Member

                                          Hi Michael, just a word of thanks that I found the pearl of wisdom on your website that solved this for me when I was having the same issue.

                                          JIC it helps others I thought I would post it inline on this Thread, cheers, Fergal

                                          // for accessing Cp variable from Flash using AS3 when embedded using Cp5:-

                                          var myRoot:MovieClip = MovieClip(root);
                                          var cpmov:MovieClip = MovieClip(myRoot.parent.root);
                                          use cpmov.variableName to access variableName in Cp Project

                                          • 18. Re: Passing Captivate Variables to Embedded swf's.
                                            www.cpguru.com Community Member

                                            Hi Fergal,

                                             

                                            Your welcome and glad to hear that the code helped you out ;o)

                                             

                                            Good idea to post it here as well so others can see it in the thread easily.

                                             

                                            /Michael


                                            Visit my Captivate blog with tips & tricks, tutorials and Widgets.

                                            • 19. Re: Passing Captivate Variables to Embedded swf's.
                                              jeremyaho

                                              I can get this to work using _root.movie.cpInfoCurrentSlide; but only if I play the published .swf directly - when embedded in html, the variable returns undefined.

                                               

                                              I've used _root, _parent, _parent.parent, etc. and only _root works in the .swf - none work through a browser. Did I miss a step?

                                               

                                              Thanks.

                                              • 20. Re: Passing Captivate Variables to Embedded swf's.
                                                Derrin Edwards Community Member

                                                Hi Geotrice,

                                                 

                                                Did you find a solution to this problem? I have exactly the same issue and its driving me nuts! Any help would be greatly appreciated.

                                                 

                                                My code is as follows:

                                                 

                                                var count = MovieClip(root).rdinfoCurrentSlide;
                                                slidenum.text = String(count);
                                                totalslidenum.text = String("of   " + 99);

                                                 

                                                All i get returned is 'undefined',

                                                 

                                                Thanks,

                                                Derrin

                                                • 21. Re: Passing Captivate Variables to Embedded swf's.
                                                  Derrin Edwards Community Member

                                                  Hi Geotrice,

                                                   

                                                  Did you find a solution to this problem? I have exactly the same issue and its driving me nuts! Any help would be greatly appreciated.

                                                   

                                                  My code is as follows:

                                                   

                                                  var count = MovieClip(root).rdinfoCurrentSlide;
                                                  slidenum.text = String(count);

                                                   

                                                  All i get returned is 'undefined',

                                                   

                                                  Thanks,

                                                  Derrin

                                                   

                                                   

                                                   

                                                   

                                                   

                                                  • 22. Re: Passing Captivate Variables to Embedded swf's.
                                                    Maxim K Community Member

                                                    In my own experience the easiest way to pass variable values between Captivate and embedded Flash is to use widgets. Then, the easiest way to write widgets is to use the Captivate Widget Factory 5 API (google it), as the native Adobe widgeting is far from being elegant.

                                                     

                                                    Widgets are a natural way to integrate external AS code into Captivate, they also allow you to control the flow of the original lesson from AS code.

                                                    • 23. Re: Passing Captivate Variables to Embedded swf's.
                                                      www.cpguru.com Community Member

                                                      There is an issue with getting some variables returned by using the code above. The slide number variables are "bugged". If you manage to actually get the variables then they will show the wrong count.

                                                       

                                                      I have always created alot of my interactivity directly in Flash and then just inserted them as animations in Captivate. However, with Captivate 5 this approach is not really working 100% anymore as you can't be sure that the variable returned is actually the correct value. Last week I spent roughly 10 hours on a gizmo I had created in Flash for Captivate. Trouble was that it was working sometimes but not every time. It used one of the slide number variables from Captivate but when I read it back I got something like 1 - 2- 0 - 1 - 4 - 1 -2 instead of 1 - 2 - 3 - 4 - 5.

                                                       

                                                      I had to recreate it as a widget and then it worked perfectly well.

                                                       

                                                      Take a look at InfoSemantics Widget Factory or Flash-Factors CPGears for an API that will allow you to create widgets quicky and painlessly.

                                                       

                                                      /Michael


                                                      Visit my Captivate blog with tips & tricks, tutorials and Widgets.

                                                       

                                                       

                                                       

                                                       

                                                       

                                                      • 24. Re: Passing Captivate Variables to Embedded swf's.
                                                        Derrin Edwards 1

                                                        Hi,

                                                         

                                                        thanks very much for the feedback Maxim K. I will definately look in to Captivate Widget Factory 5 API.

                                                         

                                                        I didn't describe my situation clearly and this may effect your thoughts. Im actually trying to control a captivate 5 swf from within a flash swf interface. I can control forward and back slide navigation but i can't manage to display the current slide number of the captivate file. I am a relative newbee to as3 so i don't really know if it is basic coding error that is the issue?

                                                         

                                                        Thanks,

                                                        Derrin

                                                        • 25. Re: Passing Captivate Variables to Embedded swf's.
                                                          Derrin Edwards 1 Community Member

                                                          Hi,

                                                           

                                                          thanks very much for the feedback CPGuru.

                                                           

                                                          Its a bit worrying that the slide variables are bugged Im actually trying to control a captivate swf displayed within a flash interface. Do you know if you can use widgets in flash (or something similar) to access info from an external captivate file?

                                                           

                                                          Thanks,

                                                          Derrin

                                                          • 26. Re: Passing Captivate Variables to Embedded swf's.
                                                            www.cpguru.com Community Member

                                                            Well that explains it. If you are trying to control a Captivate SWF from a flash interface then you are going the wrong way. The code posted here and on my site are intended to control Captivate SWFs from Flash embedded into Captivate.

                                                             

                                                            If your Flash loader it should be a simple case of referencing the instance that you loaded the Captivate SWF into followed by the appropriate Captivate System Variable.

                                                             

                                                            var myFlashVar = myInstance.myCaptivateVariable

                                                             

                                                             

                                                            /Michael


                                                            Visit my Captivate blog with tips & tricks, tutorials and Widgets.

                                                             

                                                            • 27. Re: Passing Captivate Variables to Embedded swf's.
                                                              Derrin Edwards 1 Community Member

                                                              Thanks again for your help cpguru. I'm a step closer i think, but I can only get the default numeric value returned to my dynamic text box ('NaN')?

                                                               

                                                              My as3 code is now:

                                                               

                                                              var count:Number = MovieClip(root).rdinfoCurrentFrame;
                                                              slidenum.text = String(count);

                                                               

                                                              Sorry to be a pain, but any thoughts on this issue would really be appreciated!

                                                               

                                                              Thanks,

                                                              Derrin

                                                              • 28. Re: Passing Captivate Variables to Embedded swf's.
                                                                michaeltowse Community Member

                                                                Thanks for posting this Fergal, just used the exact code on my project :-)

                                                                 

                                                                Mike

                                                                • 29. Re: Passing Captivate Variables to Embedded swf's.
                                                                  osbornsm Community Member

                                                                  Taking the code from above... var CurrentSlide = MovieClip(root).cpInfoCurrentSlide;

                                                                   

                                                                  This code it gives following:

                                                                  ReferenceError: Error #1069: Property cpInfoCurrentSlide not found on menu and there is no default value.

                                                                   

                                                                  - - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -- - - -

                                                                   

                                                                  Using the code below i get the following error message:

                                                                  TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Stage@246ebf99 to flash.display.MovieClip.

                                                                      at menu()

                                                                   

                                                                  var myRoot:MovieClip = MovieClip(root);

                                                                  var mainmov:MovieClip = MovieClip(myRoot.parent.root);

                                                                  var slide = mainmov.cpInfoCurrentSlide;

                                                                  • 30. Re: Passing Captivate Variables to Embedded swf's.
                                                                    TheFlasher_net

                                                                    Try the following code instead

                                                                     

                                                                     

                                                                    try {

                                                                        var myRoot:MovieClip = MovieClip(root);

                                                                        var mainmov:MovieClip = MovieClip(myRoot.parent.root);

                                                                        var slide = mainmov.cpInfoCurrentSlide;

                                                                    } catch (e:Error) {

                                                                        trace("You are not in Captivate");

                                                                    }

                                                                    • 31. Re: Passing Captivate Variables to Embedded swf's.
                                                                      ElginMan2007

                                                                      Hi Michael,

                                                                      So, if I'm understanding what you said, there's no way with just AS3 to get the correct slide number back from Captivate without knowing how to create a widget?

                                                                       

                                                                      If so, is your widget that gets the correct slide number available and will it pass the correct number to my .swfs?

                                                                       

                                                                      I've bought your widgets in the past and they work wonderfully so I'm hoping that your programming skills will, yet again, fill a gross deficiency in Captivate.

                                                                       

                                                                      Cheers!

                                                                      MJL

                                                                      • 32. Re: Passing Captivate Variables to Embedded swf's.
                                                                        jeremyaho Community Member

                                                                        ***Auto reply***

                                                                        Greetings. I'm out of the office and will address your message upon my return - I'll be back Monday June 11. If you have an urgent issue please call and leave voicemail and I'll do what I can to take care of it.

                                                                         

                                                                        If you have an issue regarding Learning Management, eLearning classes, or Discoverer reporting, please contact:

                                                                        Rachel Cervin Kubel (rcervin@devereux.org)

                                                                        or

                                                                        Mary Imbornone (mimborno@devereux.org) for all other issues.

                                                                         

                                                                        Thank you!

                                                                         

                                                                        >>> ElginMan2007 <forums@adobe.com> 06/08/12 10:44 >>>

                                                                         

                                                                        ElginMan2007 http://forums.adobe.com/people/ElginMan2007 created the discussion

                                                                         

                                                                        "Re: Passing Captivate Variables to Embedded swf's."

                                                                         

                                                                        To view the discussion, visit: http://forums.adobe.com/message/4476440#4476440