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.

"<br />

+ "<strong>and</strong> select 'Enter current date' from the context menu to replace the<br />

+ "currently selected text with the curr(nt date.";<br />

var my_cm:ContextMenu = new ContextMenu();<br />

my_cm.customItems.push(new ContextMenuItem("Enter current date",<br />

enterDate));<br />

function enterDate(obj:Object, menuItem:ContextMenuItem) {<br />

var today_str:String = new Date().toString();<br />

var date_str:String = today_str.split(" ", 3).join(" ");<br />

my_txt.replaceSel(date_str);<br />

}<br />

my_txt.menu = my_cm;<br />

See also<br />

setFocus (Selection.setFocus method)<br />

replaceText (TextField.replaceText method)<br />

public replaceText(beginIndex:Number, endIndex:Number, newText:String) :<br />

Void<br />

Replaces a range of characters, specified by the beginIndex <strong>and</strong> endIndex parameters, in the<br />

specified text field with the contents of the newText parameter.<br />

Parameters<br />

beginIndex:Number - The start index value for the replacement range.<br />

endIndex:Number - The end index value for the replacement range.<br />

newText:String - The text to use to replace the specified range of characters.<br />

Example<br />

The following example creates a text field called my_txt <strong>and</strong> assigns the text dog@house.net<br />

to the field. The indexOf() method is used to find the first occurrence of the specified<br />

symbol (@). If the symbol is found, the specified text (between the index of 0 <strong>and</strong> the symbol)<br />

replaces with the string bird. If the symbol is not found, an error message is displayed in the<br />

Output panel.If the symbol is not found, an error message writes to the log file.<br />

this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 320,<br />

22);<br />

my_txt.autoSize = true;<br />

my_txt.text = "dog@house.net";<br />

var symbol:String = "@";<br />

var symbolPos:Number = my_txt.text.indexOf(symbol);<br />

if (symbolPos>-1) {<br />

TextField 637

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

Saved successfully!

Ooh no, something went wrong!