method setSelection

void setSelection(int32 startPos,int32 endPos);

Argumente

Zurückgegebener Wert

This method selects the text in the edit field between the provided start and end indices. Start and end indices must be within the limits of the available number of characters in the text control. If aStart is 0 and aEndPos is -1, then all text in the control will be selected.
function SelectAllButEnd()
{
    // we are going to select all but the last 2 characters.
    var editBx = scene.getBoxById("nameEdit");
    if (editBx)
    {
        var val = editBx.value;
        if (val && (val.length > 2))
        {
            editBx.setSelection(0, val.length - 2);
        }
    }
}