actionscript 3 - Unable to delete new line if it is last character in text area flex as3 -


<mx:application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minwidth="955" minheight="600">     <mx:script>         <![cdata[                            protected function button1_clickhandler(event:mouseevent):void             {                 var str:string = textid.text;             }                        ]]>     </mx:script>     <mx:vbox>                    <mx:hbox>         <mx:textarea id="textid" restrict="^\r"/>     </mx:hbox>     <mx:hbox>         <mx:button label="click here" click="button1_clickhandler(event)" />     </mx:hbox>     </mx:vbox> </mx:application> 

first enter text as: "hi\n" in text area, see text in textid.text clicking button. delete last character text "hi". in textid.text still result showing "hi\n". new line @ end not deleted.

if don't want save whitespace characters beginning , end of entered text in textarea can use trim function below:

<fx:script>     <![cdata[     import mx.utils.stringutil;     protected function button1_clickhandler(event:mouseevent):void     {         var str:string = stringutil.trim(textid.text);         textid.text = str;     }     ]]> </fx:script> 

trim function converts " hi\n\n" "hi".


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -