• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Passing Captivate Variables to Embedded swf's.

Explorer ,
Oct 16, 2009 Oct 16, 2009

Copy link to clipboard

Copied

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

TOPICS
Advanced

Views

11.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Oct 21, 2009 Oct 21, 2009

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.

Votes

Translate

Translate
Advisor ,
Oct 18, 2009 Oct 18, 2009

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 19, 2009 Oct 19, 2009

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 19, 2009 Oct 19, 2009

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 19, 2009 Oct 19, 2009

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 20, 2009 Oct 20, 2009

Copy link to clipboard

Copied

/Michael

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

-S

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 20, 2009 Oct 20, 2009

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 21, 2009 Oct 21, 2009

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 21, 2009 Oct 21, 2009

Copy link to clipboard

Copied

/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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 11, 2009 Nov 11, 2009

Copy link to clipboard

Copied

This is super helpful!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 17, 2010 Mar 17, 2010

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Mar 18, 2010 Mar 18, 2010

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 25, 2010 Mar 25, 2010

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Mar 25, 2010 Mar 25, 2010

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 14, 2010 Jul 14, 2010

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 16, 2010 Jul 16, 2010

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 27, 2010 Aug 27, 2010

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Aug 28, 2010 Aug 28, 2010

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 15, 2012 Jan 15, 2012

Copy link to clipboard

Copied

Thanks for posting this Fergal, just used the exact code on my project 🙂

Mike

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 13, 2011 Jan 13, 2011

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 13, 2011 Jan 13, 2011

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jan 13, 2011 Jan 13, 2011

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 13, 2011 Jan 13, 2011

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jan 13, 2011 Jan 13, 2011

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 14, 2011 Jan 14, 2011

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources