Chapter 21. Reading and Writing Data Files

FileIO Xtra Basics

Using text files has always been more difficult in Director than it should be. Director MX is no different. It requires you to use the FileIO Xtra. This Xtra adds Lingo commands to handle reading and writing files.

Using an Xtra such as this is like using a behavior, except that the Xtra is referenced through a variable, not a sprite. Here is an example. To read a text file, use the following series of commands:

fileObj = new(xtra "FileIO") fileObj .openFile("myfile.txt", 1) text = fileObj.readfile() ...

Get Special Edition Using® Macromedia® Director® MX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.