I have a dynamic TextField with code on it. Normally, if you select text and then hit the up key your selection would move up. I want to prevent this behavior, because I’m using the UP key to tighten the leading.
I would think that “e.stopPropagation();” but then I realized that the event is happening on the same place.
The only thing I could think of is to capture the selectionBeginIndex and the [URL=“http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html#selectionEndIndex”]selectionEndIndex and then after the KeyboardEvent call the [URL=“http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html#setSelection%28%29”]setSelection method.
Any thoughts?
kerningTextField.addEventListener(KeyboardEvent.KEY_DOWN, updateKerning)
function updateKerning(e:KeyboardEvent)
{
if(e.shiftKey)
{
trace("keyboardEvent with shift pressed");
var currentTextFormat:TextFormat
switch(e.keyCode) //Up Key
{
case 38: //Up key
currentTextFormat = kerningTextField.getTextFormat();
trace(currentTextFormat.leading);
currentTextFormat.leading = Number(currentTextFormat.leading) - 1;
kerningTextField.setTextFormat(currentTextFormat);
e.stopPropagation();
break;
case 40: //Down key
currentTextFormat = kerningTextField.getTextFormat();
trace(currentTextFormat.leading);
currentTextFormat.leading = Number(currentTextFormat.leading) + 1;
kerningTextField.setTextFormat(currentTextFormat);
e.stopPropagation();
break;
}
}
}