读书人

flex 剔除选中内容

发布时间: 2012-10-29 10:03:53 作者: rapoo

flex 删除选中内容

<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600"creationComplete=""><mx:Script>   <![CDATA[//function onclick(e:MouseEvent):void {// txt.text += e.target.label; //} protected function deleteChar(event:MouseEvent):void{var s:String = txt.text; var begin:int = txt.selectionBeginIndex; var end:int = txt.selectionEndIndex;  if(begin!= end)  {  txt.text = s.substring(0, begin) + s.substring(end);  } else{  txt.text = s.substring(0, begin - 1) + s.substring(end);  }}   ]]>    </mx:Script><mx:TextInput id="txt" width="330" height="47"/><!-- 点击”删除“按钮,删除光标前面的一个字符,如果选中了内容之后,直接删除选中内容--><mx:Button label="删除" click="deleteChar(event)" x="10" y="55" width="109" height="39"/></mx:Application>

读书人网 >flex

热点推荐