Back to Previous

Forms & Writing To Files

Creating CD-Rom titles that record text information is a fairly easy task. But what if you want to read or write the information to a external rich text file (.RTF)?

The solution is to then use director's built in FileI/O Xtra along with a few special behaviors that are based on the "File I/O" & "read/write PrefsFile" behaviors that comes in the director application's learning folder.

In there standard format, these movie/sprite script behaviors write the contents of a text field to a preference file deep inside the users computer that has been triggered via the submission of a button that has the "writePresfile" behavior. In addition, you can also read the text file back in. It's a little more than that, but the bottom line is that although very useful, they are still quite limiting.

As such, I have created the following 4 behaviors that will read, write and even append director text to a RTF file that will get saved to any area you specify on the users C: drive or other drive for that matter.

Behaviors used: Write RTF File, Append RTF File, File In-Out Plus, Read  RTF File

Since it is an RTF file as opposed to a .TXT (text file), you can also add headers to the file that describes what the information as well as spaces and separation lines for readability . More details can be found in the behavior's comments.

The sample below will write the contents of the yellow text field along with a header called "Yellow's Text" to a RTF file called "info.rtf". It will also save the good or bad radio button answer that is chosen as well.  This file will automatically get created in the root of your C: Drive. Further submissions via the "append new answers" button will continue to add a separation line and append this on-going file. You can read back the file as well by selecting the large read button.

Unfortunately this feature is not supported in shockwave due to security measures built into the shockwave web plugin. However this does work fine as a projector. Included below is a screenshot and a windows projector exe for you to try out.

download example