getTextRunInfo (TextSnapshot.getTextRunInfo method)

public getTextRunInfo(beginIndex:Number, endIndex:Number) : Array

Returns an array of objects that contains information about a run of text. Each object corresponds to one character in the range of characters specified by the two method parameters.

Note: Using the getTextRunInfo() method for a large range of text can return a large object. Adobe recommends limiting the text range defined by the beginIndex and endIndex parameters.

Availability: ActionScript 1.0; Flash Player 7 - The SWF file must be published for Flash Player 6 or later, and must be played in Flash Player 7r19 or later.

Parameters

beginIndex:Number - The index value of the first character in the range of characters.

endIndex:Number - The index value of the last character in the range of characters.

Returns

Array - An array of objects in which each object contains information about a specific character in the specified range. Each object contains the following properties:

Example

The following example illustrates how to use this method. To use this code, on the Stage create a static text field that contains the text "AB". Rotate the text field by 45 degrees, and set the second character to be superscript with a color of 0xFFFFFF with a 50% alpha, as the following figure shows:

The following script lists the getTextRunInfo() properties of each character in the text field:

var myTS:TextSnapshot = this.getTextSnapshot();
var myArray:Array = myTS["getTextRunInfo"](0, myTS.getCount());
for (var i = 0; i < myTS.getCount(); i++) {
    trace("indexInRun: " + myArray[i].indexInRun);
    trace("selected: " + myArray[i].selected);
    trace("font: " + myArray[i].font);
    trace("color: " + decToHex(myArray[i].color));
    trace("height: " + myArray[i].height);
    trace("matrix_a: " + myArray[i].matrix_a);
    trace("matrix_b: " + myArray[i].matrix_b);
    trace("matrix_c: " + myArray[i].matrix_c);
    trace("matrix_d: " + myArray[i].matrix_d);
    trace("matrix_ty: " + myArray[i].matrix_tx);
    trace("matrix_tx: " + myArray[i].matrix_ty);
    trace(" ");
}

function decToHex(dec:Number) {
    var hexString:String = "";
    if (dec > 15) {
        hexString = decToHex(Math.floor(dec / 16));
    }
    var hexDigit = dec - 16 * (Math.floor(dec / 16)); 
        if (hexDigit > 9) {
            hexDigit = String.fromCharCode(hexDigit + 55);
        }
        hexString = hexString + hexDigit;
        return hexString;
}

This creates the following output:

indexInRun: 0
selected: false
font: Times New Roman
color: FF000000
height: 28.6
matrix_a: 0.0316612236983293
matrix_b: 0.0385940558426864
matrix_c: -0.0385940558426864
matrix_d: 0.0316612236983293
matrix_ty: 22.75
matrix_tx: 40.35
    
indexInRun: 0
selected: false
font: Times New Roman
color: 80000000
height: 28.6
matrix_a: 0.0316612236983293
matrix_b: 0.0385940558426864
matrix_c: -0.0385940558426864
matrix_d: 0.0316612236983293
matrix_ty: 49
matrix_tx: 45.5

This example uses a decToHex() method to convert the decimal value of the color property to a hexadecimal value.

See also

Matrix (flash.geom.Matrix)