Skip to main content
Inspiring
March 17, 2010
Answered

Dynamic Content?

  • March 17, 2010
  • 2 replies
  • 1494 views

I'm wondering how to load dynamic content into a CP4 project at run time?  For example, is it possible to have variables assigned values from a text file of some sort at run time?  The result would be text captions that could display different (variable) text each time it's run.  I'm thinking of doing this on a local PC rather than a web server.  The associated text file should be something that is easily editible, like with Notepad.

Thanks for any insights.

Mister C.

This topic has been closed for replies.
Correct answer www_cpguru_com

You can do this with Flash and text files and it is not a complicated task. It will also run locally on your PC since that it within one "security zone" in Flash. The security problem is an issue if you run a Flash file locally and try to access online content or vice versa.

A simple example of how to do this is as follows:

1. Create an AS2 Flash file

2. Insert a Dynamic Text box by using the text tool.

3. Give your dynamic text box an instance name (in this example myText_txt)

4. Press F9 to open up the actions panel

5. Copy / paste the following code:

this.stop();
myData = new LoadVars();
myData.onLoad = function() {
myText_txt.html=true;
myText_txt.htmlText = this.myVariable;
};
myData.load("text1.txt");

6. Create a textfile in Notepad (always use UTF-8 encoding) and name it "text1.txt".

7. In the texfile write myVariable=Your message that you want to show up in Flash / Captivate

8. Save and publish your Flash file

9. Import the Flash file into your Captivate slide.

10. Publish your Captivate project.

11. Manually copy the text1.txt file to the directory you published to.

12. Enjoy!

Flash source file, Captivate file etc. attached as a zip package here in this post.

EDIT:  Hmm..where did the upload file thingy in the forum go? Anyways the zip file can be downloaded here: www.cpguru.com//demonstrations/cpFlashText.zip

Now this is an extremely simple example but it could be expanded upon to included formatting the txt in HTML format (e.g. bold, italic, font size etc.) or it could be turned into a widget that would load a new line of your text file on each slide. This does require alot more coding though, but it would be possible.

Hope this helps.

/Michael


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

Message was edited by: www.cpguru.com

2 replies

May 31, 2010

Hi!

I wonder if there is a way to expand this kind of solution, which will make it possible to have not just a single text box dynamic, but also the interactive elements that are created on recording. This will be helpful when having a project in which a separation of the animation and text (for example in an xml file) is needed.

Any ideas?

Erik Lord
Inspiring
March 17, 2010

It's likely possible but would require fancy actionscripting...or maybe not fancy actionscripting...maybe plain actionscripting....but some sort of AS skill.

However, you wouldn't be able to read from a local .txt file - I don't believe the Flash Player security will allow that. You could likely read from a web location - via XML most likely. You could also read from the local sharedObject, but you'd have to devise a way to write to it for editing first (like another Flash app for creating the text in the sharedObject, then your CP app for reading from it).

Flash with AIR would likely be a better approach?

Erik

Inspiring
March 17, 2010

Hi Eric.  Thanks for your post.  I was afraid it would take something like Flash.  My Flash skills are pretty limited --- I can create a simple motion tween, but that's about it.  My brain won't wrap itself around AS3.  Give me something simple --- like Cobol.

Mister C.

Captiv8r
Legend
March 18, 2010

"Give me something simple, like COBOL". HAHAHAHAHAHAHAHAHAAAAA! (I miss the simplicity of COBOL too.)

Thanks for the chuckle Mister C!

Sounds like you and I are in similar boats. I really wish I had an understanding of Flash. That and PhotoShop. I open each of those applications and go "What now?". And mostly I'm afraid to touch anything for fear I'll click some obscure button that will totally rearrange the interface and suddenly it will be unusable. Which is funny actually, because I don't know how to use the interface that's already there!

Cheers... Rick

Helpful and Handy Links

Captivate Wish Form/Bug Reporting Form

Adobe Certified Captivate Training

SorcerStone Blog

Captivate eBooks