Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy this TLFTextField code works only once?
    primarykey
    data
    text
    <p>I need the text in an input TLF text field to be modified when the user changes it. As for example, I'm trying to make it uppercase every time the user adds or deletes a character:</p> <pre><code>import fl.text.TLFTextField; import flashx.textLayout.formats.TextLayoutFormat; import flashx.textLayout.elements.TextFlow; var myTLFTextField:TLFTextField = new TLFTextField(); addChild(myTLFTextField); myTLFTextField.x = 10; myTLFTextField.y = 10; myTLFTextField.width = 200 myTLFTextField.height = 100; myTLFTextField.text = "This is my text"; 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(Event.CHANGE, this.onTextFieldChange); function onTextFieldChange(event:Event):void { myTLFTextField.text = myTLFTextField.text.toUpperCase(); } </code></pre> <p>The code that goes before <code>//--</code> is taken from the <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/text/TLFTextField.html" rel="nofollow">TLFTextField documentation</a>, the very first example on the page.</p> <p>When I try to edit the text, it does become uppercase, but after that the text field stops responding to any input and the output says</p> <blockquote> <p>TypeError: Error #1009: Cannot access a property or method of a null object reference. at flashx.textLayout.container::TextContainerManager/getController() at flashx.textLayout.container::TextContainerManager/mouseDownHandler()</p> </blockquote> <p>When I comment out the <code>addEventListener</code> line, all appears to be working fine.</p> <p>Does it mean that it's not possible to make changes to the text in a TLF text field on user input event like it is possible with the classic text fields?</p>
    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.
 

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