|
SelectionManager
/** * @author: Eric Feminella * @url: http://www.ericfeminella.com * @copyright: (c)2004 - 2006 code.ericfeminella.com */ import mx.controls.TextArea; class com.displays.SelectionManager { public static var caretIndex:Number; public static var mouseEvent:Boolean; public static var lastIndex:Number = 0; public function SelectionManager() { this.initUserEvent(); } private function initUserEvent():Void { var mouseListenerObject:Object = {}; mouseListenerObject.onMouseUp = SelectionManager.onSetFocus; Mouse.addListener(mouseListenerObject); } public static function onSetFocus():Void { if (Selection.getCaretIndex() != -1) { SelectionManager.caretIndex = Selection.getCaretIndex(); SelectionManager.mouseEvent = true; SelectionManager.lastIndex = 0; } } public function insertAtSelectedIndex(stringToInsert:String, selectedTextArea:TextArea):String { var index:Number = this.getIndex(stringToInsert.length); var originalString:String = selectedTextArea.text; var originalStringLength:Number = originalString.length; var selectionStart:String = originalString.substring(0, index); var selectionEnd:String = originalString.substring(index, originalStringLength); var newString:String = selectionStart + " " + stringToInsert + " " + selectionEnd; return newString; } private function getIndex(stringToInsertLength:Number):Number { if (SelectionManager.mouseEvent) { var index:Number = SelectionManager.caretIndex; SelectionManager.lastIndex = index + stringToInsertLength + 2; } else { var index:Number = SelectionManager.lastIndex + stringToInsertLength; SelectionManager.lastIndex = index + 2; } SelectionManager.mouseEvent = false; return index; } } Posted by: Eric Feminella | website http://www.ericfeminella.com |
onClipEvent (keyDown) {
if (Selection.getFocus() == "_level0.movieClip.textboxVariable1"&&Key.isDown(Key.TAB)) {
Selection.setFocus( "_level0.movieClip.textboxVariable2");
} else if (Selection.getFocus() == "_level0.movieClip.textboxVariable2"&&Key.isDown(Key.TAB)) {
Selection.setFocus( "_level0.movieClip.textboxVariable3");
} else if (Selection.getFocus() == "_level0.movieClip.textboxVariable3"&&Key.isDown(Key.TAB)) {
Selection.setFocus( "_level0.movieClip.textboxVariable1");
}
}
//Or if you'd rather place the actions on a button, try this:
on (keyPress "") {
if (Selection.getFocus() == "_level0.movieClip.textboxVariable1") {
Selection.setFocus( "_level0.movieClip.textboxVariable2");
} else if (Selection.getFocus() == "_level0.movieClip.textboxVariable2") {
Selection.setFocus( "_level0.movieClip.textboxVariable3");
} else if (Selection.getFocus() == "_level0.movieClip.textboxVariable3") {
Selection.setFocus( "_level0.movieClip.textboxVariable1");
}
}
Posted by: No name | website http:// |
// Define following function in the same frame with the component
// Call it at the Property inspector as a Change Handler
function callURL() {
getURL(listBox.getSelectedItem().data, "_blank");
}
// Instance name for the component is "listbox"
// Source file can be seen at "Scripting" category at "Movies" section.
Posted by: Mustafa Basgun | website http://www.basgun.com |

