03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

See also<br />

getFocus (Selection.getFocus method)<br />

setSelection (Selection.setSelection method)<br />

public static setSelection(beginIndex:Number, endIndex:Number) : Void<br />

Sets the selection span of the currently focused text field. The new selection span begins at the<br />

index specified in the beginIndex parameter, <strong>and</strong> ends at the index specified in the endIndex<br />

parameter. Selection span indexes are zero-based (for example, the first position is 0, the<br />

second position is 1, <strong>and</strong> so on). This method has no effect if no text field currently has focus.<br />

When you call the setSelection() method <strong>and</strong> a text control has focus, the selection<br />

highlight is drawn only when the text field is being actively edited. The setSelection()<br />

method can be invoked after Selection.setFocus() or from within an onSetFocus()<br />

event h<strong>and</strong>ler, but any selection is visible only following a call to the fscomm<strong>and</strong><br />

activateTextField comm<strong>and</strong>.<br />

Parameters<br />

beginIndex:Number - The beginning index of the selection span.<br />

endIndex:Number - The ending index of the selection span.<br />

Example<br />

The following ActionScript code creates a text field at runtime <strong>and</strong> adds a string to it. Then it<br />

assigns an event h<strong>and</strong>ler for the onSetFocus event that selects all the text in the text field <strong>and</strong><br />

activates the editing session.<br />

Note: If the Selection.setSelection() method is called, the text is not drawn on screen<br />

until the text field is activated (following a call to the fscomm<strong>and</strong> activateTextField<br />

comm<strong>and</strong>).<br />

this.createTextField("myText_txt", 99, 10, 10, 200, 30);<br />

myText_txt.type = "input";<br />

myText_txt.text = "this is my text";<br />

myText_txt.onSetFocus = function(){<br />

Selection.setSelection(0,myText_txt.text.length);<br />

fscomm<strong>and</strong>("activateTextField");<br />

}<br />

The following example illustrates how the endIndex parameter is not inclusive. In order to<br />

select the first character, you must use an endIndex of 1, not 0. If you change the endIndex<br />

parameter to 0, nothing will be selected.<br />

this.createTextField("myText_txt", 99, 10, 10, 200, 30);<br />

myText_txt.text = "this is my text";<br />

550 ActionScript classes

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!