User Guide

258 Chapter 12: Methods
charPosToLoc()
Usage
--Lingo syntax
memberObjRef.charPosToLoc(nthCharacter)
// JavaScript syntax
memberObjRef.charPosToLoc(nthCharacter);
Description
Field function; returns the point in the entire field cast member (not just the part that appears on
the Stage) that is closest to a specified character. This is useful for determining the location of
individual characters.
Values for
charPosToLoc are in pixels from the top left corner of the field cast member. The
nthCharacter parameter is 1 for the first character in the field, 2 for the second character, and
so on.
Parameters
nthCharacter
Required. The character to test.
Example
The following statement determines the point where the fiftieth character in the field cast
member Headline appears and assigns the result to the variable location:
-- Lingo syntax
location = member("Headline").charPosToLoc(50)
// JavaScript syntax
var location = member("Headline").charPosToLoc(50);
chars()
Usage
chars(stringExpression, firstCharacter, lastCharacter)
Description
Function (Lingo only); identifies a substring of characters in an expression.
The expressions
firstCharacter and lastCharacter must specify a position in the string.
If
firstCharacter and lastCharacter are equal, then a single character is returned from the
string. If
lastCharacter is greater than the string length, only a substring up to the length of the
string is identified. If
lastCharacter is before firstCharacter, the function returns the value
EMPTY.
To see an example of
chars() used in a completed movie, see the Text movie in the Learning/
Lingo folder inside the Director application folder.
In JavaScript syntax, use the String objects
substr() function.