Skip navigation
sgovernale
Currently Being Moderated

Passing Captivate Variables to Embedded swf's.

Oct 16, 2009 11:57 AM

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

 
Replies
  • Currently Being Moderated
    Oct 18, 2009 9:35 AM   in reply to sgovernale

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 19, 2009 11:42 PM   in reply to sgovernale

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 20, 2009 12:18 PM   in reply to www.cpguru.com

    /Michael

     

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

     

    -S

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 20, 2009 12:59 PM   in reply to sdgovernale

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 21, 2009 12:31 AM   in reply to sdgovernale

    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%8 0%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.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 11, 2009 3:11 PM   in reply to www.cpguru.com

    This is super helpful!

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 17, 2010 11:46 AM   in reply to www.cpguru.com

    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!

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 18, 2010 1:40 AM   in reply to skyland_mp

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 25, 2010 7:20 AM   in reply to www.cpguru.com

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 25, 2010 7:35 AM   in reply to ML021469

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 14, 2010 8:45 AM   in reply to www.cpguru.com

    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-8B B8-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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 16, 2010 2:40 PM   in reply to geotrice

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 26, 2010 3:35 AM   in reply to sgovernale

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 27, 2010 8:09 AM   in reply to www.cpguru.com

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 28, 2010 2:18 AM   in reply to Fergal Mohan

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 31, 2010 12:18 PM   in reply to www.cpguru.com

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 13, 2011 10:43 AM   in reply to geotrice

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 13, 2011 10:45 AM   in reply to Derrin Edwards

    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

     

     

     

     

     

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 13, 2011 11:25 AM   in reply to sgovernale

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 13, 2011 11:34 AM   in reply to Derrin Edwards

    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.

     

     

     

     

     

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 13, 2011 2:42 PM   in reply to Maxim K

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 13, 2011 2:46 PM   in reply to www.cpguru.com

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 13, 2011 11:22 PM   in reply to Derrin Edwards 1

    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.

     

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 14, 2011 1:24 AM   in reply to www.cpguru.com

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 15, 2012 6:35 AM   in reply to Fergal Mohan

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

     

    Mike

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 16, 2012 1:52 PM   in reply to www.cpguru.com

    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;

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 17, 2012 5:49 AM   in reply to osbornsm

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

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 8, 2012 7:44 AM   in reply to www.cpguru.com

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 8, 2012 7:45 AM   in reply to ElginMan2007

    ***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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (1)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points