Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Why? Because TLF has got problems. As others have pointed out, changing TLF text inside an Event.CHANGE handler causes the change handler to be called a second time. At that point, things break down.</p> <p>I had come up with a solution that's similar to the one @Abe posted, but it's more general – it doesn't rely on checking for upper case characters. You listen for TextEvent.TEXT_INPUT, then toggle an Event.CHANGE listener inside the text input handler.</p> <pre><code>import fl.text.TLFTextField; import flashx.textLayout.formats.TextLayoutFormat; import flashx.textLayout.elements.TextFlow; import flash.text.TextFieldType; import flash.events.TextEvent; var myTLFTextField:TLFTextField = new TLFTextField(); addChild(myTLFTextField); myTLFTextField.x = 10; myTLFTextField.y = 10; myTLFTextField.width = 500 myTLFTextField.height = 100; myTLFTextField.text = "This is my text"; myTLFTextField.border = true; myTLFTextField.multiline = true; myTLFTextField.type = TextFieldType.INPUT; var myFormat:TextLayoutFormat = new TextLayoutFormat(); myFormat.textIndent = 8; myFormat.color = 0x336633; myFormat.fontFamily = "Arial, Helvetica, _sans"; myFormat.fontSize = 24; var myTextFlow:TextFlow = myTLFTextField.textFlow; myTextFlow.hostFormat = myFormat; myTextFlow.flowComposer.updateAllControllers(); myTLFTextField.addEventListener(TextEvent.TEXT_INPUT, onTextInput); var selectionIndex:uint; function onTextInput(e:TextEvent):void { trace("onTextInput"); selectionIndex = myTLFTextField.selectionEndIndex; myTLFTextField.addEventListener(Event.CHANGE, onTextChanged); } function onTextChanged(e:Event):void { trace("onTextChanged"); myTLFTextField.removeEventListener(Event.CHANGE, onTextChanged); // Do whatever you need to do here: myTLFTextField.text = myTLFTextField.text.toUpperCase(); myTLFTextField.setSelection(selectionIndex + 1, selectionIndex + 1); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload