您好,登錄后才能下訂單哦!
這篇文章主要介紹Flex組件開(kāi)發(fā)的示例分析,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
Flex組件開(kāi)發(fā)總結(jié)
在平時(shí)的Flex開(kāi)發(fā)過(guò)程中遇到的問(wèn)題以及解決辦法總結(jié)如下:
1.如何監(jiān)聽(tīng)鍵盤(pán)事件?
<mx:TextAreaidmx:TextAreaid="textEditor"keyDown="sendKeyHandler(event)"x="11"y="366"width="399"/> privatefunctionsendKeyHandler(evt:KeyboardEvent):void { //Enter鍵 if(evt.keyCode==13) { this.sendTxt(); return; } }
代碼說(shuō)明:有兩種類(lèi)型的鍵盤(pán)事件:KeyboardEvent.KEY_DOWN和KeyboardEvent.KEY_UP
以上是監(jiān)聽(tīng)的是回車(chē)事件
要是想監(jiān)聽(tīng)組合鍵,例如:Ctrl+Enter鍵,代碼如下:
if(evt.keyCode==13&&evt.ctrlKey) { }
2.Flex開(kāi)發(fā)中怎么控制RichTextEditor的控制欄?
利用showControlBar屬性,控制RichTextEditor的控制欄,這樣把整個(gè)控制欄都關(guān)閉了
要是想分別控制控制欄中各寄宿控件,可以參考如下代碼:
this.textEditor.alignButtons.height=0; this.textEditor.alignButtons.visible=false; this.textEditor.bulletButton.height=0; this.textEditor.bulletButton.visible=false; this.textEditor.linkTextInput.height=0; this.textEditor.linkTextInput.visible=false; this.textEditor._RichTextEditor_VRule1.height=0; this.textEditor._RichTextEditor_VRule1.visible=false; this.textEditor._RichTextEditor_VRule2.height=0; this.textEditor._RichTextEditor_VRule2.visible=false;
當(dāng)然,還可以參考這文章
http://blog.minidx.com/2008/12/29/1841.html
3.Flex開(kāi)發(fā)中控件雙擊事件(DoubleClickEvent)怎么沒(méi)反應(yīng)?
<mx:ButtondoubleClickEnabledmx:ButtondoubleClickEnabled="true"doubleClick="doubleClickHandler(event)"x="48"y="32"label="Button"/> privatefunctiondoubleClickHandler(evt:MouseEvent):void { Alert.show("doubleClick"); }
代碼說(shuō)明:
doubleClickEnabled屬性:指定對(duì)象是否接收doubleClick事件。默認(rèn)值為false,這意味著在默認(rèn)情況下,不接收doubleClick事件。如果將doubleClickEnabled屬性設(shè)置為true,實(shí)例在其范圍內(nèi)接收doubleClick事件
4.Flex開(kāi)發(fā)中怎么在TextArea的光標(biāo)位置插入字符?
<mx:TextAreaidmx:TextAreaid="textEditor"x="11"y="366"width="399"/> privatefunctioninsertString(insertStr:String):void { if(this.textEditor.selectionBeginIndex==this.textEditor.selectionEndIndex) { varstartPart:String=this.textEditor.text.substring(0,this.textEditor.selectionBeginIndex); varendPart:String=this.textEditor.text.substring(this.textEditor.selectionEndIndex,this.textEditor.text.length); startPart+=insertStr; startPart+=endPart; this.textEditor.text=startPart; } else { this.textEditor.text=insertStr; } }
5.Flex開(kāi)發(fā)中如何實(shí)現(xiàn)TextArea控件的滾動(dòng)條始終保持在最下面?
this.txt_content.addEventListener(FlexEvent.VALUE_COMMIT,VALUE_COMMITHandler); privatefunctionVALUE_COMMITHandler(evt:FlexEvent):void{ txt_contenttxt_content.verticalScrollPosition=txt_content.maxVerticalScrollPosition; }
代碼說(shuō)明:這段代碼是為了實(shí)現(xiàn)TextArea控件的滾動(dòng)條始終保持在最下面,以方便用戶查看聊天信息
要是VBox控件需要實(shí)現(xiàn)類(lèi)似效果,可以看如下代碼:
<mx:VBoxidmx:VBoxid="vd"updateComplete="updateCompleteHandler(event)"x="10"y="10"width="399"height="348"> privatefunctionupdateCompleteHandler(evt:FlexEvent):void { thisthis.vd.verticalScrollPosition=this.vd.maxVerticalScrollPosition; }
以上是“Flex組件開(kāi)發(fā)的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。