Director Help

setPref()

Usage

-- Lingo syntax
_player.setPref(stringPrefName, prefString)

// JavaScript syntax
_player.setPref(stringPrefName, prefString);

Description

Player method; writes the string specified by prefString in the file specified by stringPrefName on the computer’s local disk.

The stringPrefName argument must be a valid filename. To make sure the filename is valid on all platforms, use no more than eight alphanumeric characters for the file name.

After the setPref() method runs, if the movie is playing in a browser, a folder named Prefs is created in the Plug-In Support folder. The setPref() method can write only to that folder.

If the movie is playing in a projector or Director, a folder is created in the same folder as the application. The folder receives the name Prefs.

Do not use this method to write to read-only media. Depending on the platform and version of the operating system, you may encounter errors or other problems.

This method does not perform any sophisticated manipulation of the string data or its formatting. You must perform any formatting or other manipulation in conjunction with getPref(); you can manipulate the data in memory and write it over the old file using setPref().

In a browser, data written by setPref() is not private; any movie with Shockwave content can read this information and upload it to a server. Do not store confidential information using setPref().

On Windows, the setPref() method fails if the user is a restricted user.

To see an example of setPref() used in a completed movie, see the Read and Write Text movie in the Learning/Lingo folder inside the Director application folder.

Parameters

stringPrefName Required. A string that specifies the name of the file to which the string prefString is written. The file is a standard text file.

prefString Required. The string to write to the file specified by stringPrefName.

Example

This handler saves the contents of the field cast member Text Entry in a file named DayWare settings:

-- Lingo syntax
on mouseUp me
    _player.setPref("CurPrefs", member("Text Entry").text)
end

// JavaScript syntax
function mouseUp() {
    _player.setPref("CurPrefs", member("Text Entry").text);
}

See also

getPref(), Player