我需要訪問組合框子(textinput和按鈕)而不創建自定義組件。我知道最好的做法是創建一個自定義組件,但仍然需要訪問像textinput一樣的組合框子並監聽它們的事件。任何幫助?Flex組合框子(textInput,按鈕)訪問
0
A
回答
0
您可以將事件添加到您的ComboBox控件的TextInput這樣。
這裏是一個完整的工作示例
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="creationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
import spark.events.IndexChangeEvent;
import spark.events.TextOperationEvent;
[Bindable]
private var _dp:ArrayCollection = new ArrayCollection([
{id : "1", name : "Paul"},
{id : "2", name : "Andrew"},
{id : "2", name : "Bob"}
]);
protected function creationCompleteHandler(event:FlexEvent):void
{
myComboBox.textInput.addEventListener(TextOperationEvent.CHANGE, showTextInputValue);
myComboBox.addEventListener(IndexChangeEvent.CHANGE, showComboValue);
}
protected function showTextInputValue(event:TextOperationEvent):void
{
textFieldValue.text = "myComboBox.textInput : " + event.currentTarget.text;
}
protected function showComboValue(event:IndexChangeEvent):void
{
if (event.newIndex > -1)
comboBoxValue.text = "myComboBox selected item is : " + myComboBox.selectedItem.name;
}
]]>
</fx:Script>
<s:layout>
<s:VerticalLayout/>
</s:layout>
<s:ComboBox id="myComboBox" labelField="name" dataProvider="{_dp}"/>
<mx:Spacer height="100"/>
<s:Label id="textFieldValue"/>
<s:Label id="comboBoxValue"/>
</s:WindowedApplication>
0
您可以爲Event.ADDED
事件偵聽器添加到組合框和檢查event.target
的類型針點所需的顯示對象(例如if (event.target is TextField) doStuff();
),您將無法訪問該組合框的財產(以取代文本字段或不同的按鈕),但您可以修改已添加到舞臺的實例。因爲TextInput對象是ComboBox對象(myComboBox.textInput)的孩子
myComboBox.textInput.addEventListener(TextOperationEvent.CHANGE, myFunction);
:
相關問題
- 1. 帶TextInput的Flex警報以及按鈕
- 2. TextInput flex 4.6中的Alt + charkey組合
- 3. 檢測Flex中可編輯組合框上的TextInput更改
- 4. Multibinding與組合框按鈕
- 5. 訪問消息框按鈕
- 6. 的Flex組合框綁定問題
- 7. 訪問查詢/組合框
- 8. 微軟訪問組合框
- 9. 訪問2010日組合框
- 10. 訪問組合框請求
- 11. 訪問組合框值
- 12. AS3 /閃光:組合框和TextInput互動
- 13. 組合框按鈕,文本框的Java
- 14. 訪問textInput on onSubmitEnding
- 15. 訪問火花TextInput組件的contextMenu
- 16. 使用flex TextInput和按鈕在MySQL中插入數據
- 17. 如何放置按鈕的TextInput內部Flex中4.6
- 18. 移除ajaxtoolkit組合框的樣式組合框按鈕
- 19. Flex愛斯基摩組合框 - textinput在彈出窗口上顯示
- 20. 訪問組合框填充文本框
- 21. Flex中的組合框
- 22. Flex延伸組合框
- 23. Flex可編輯組合框
- 24. 訪問VBA中的組合框問題
- 25. 訪問按鈕
- 26. 訪問按鈕
- 27. 如何訪問Flex TextInput控件中的選定文本
- 28. WPF組合框箭頭按鈕
- 29. WPF在組合框中添加按鈕
- 30. 與ios組合框的繪製按鈕