fujingrun 2010-03-26 21:34
浏览 493
已采纳

怎么才能得到 combox 下拉框中的值

  [color=darkred]<?xml version="1.0" encoding="utf-8"?>



mx:ArrayCollection


/mx:ArrayCollection
/mx:ComboBox
mx:Script
<![CDATA[
import mx.controls.Alert;
import flash.events.Event;
public function myTestDispaly(event:flash.events.Event):void{
mx.controls.Alert.show();
}

    public function init():void{
        combox.addEventListener(flash.events.Event.CHANGE,myTestDispaly);
    }
    ]]>
</mx:Script>

/mx:Application[/color]

怎么在这个方法中 public function myTestDispaly(event:flash.events.Event):void{
mx.controls.Alert.show();
}
得到 combox 中的值?

各位 谢谢了

  • 写回答

1条回答 默认 最新

  • suziwen 2010-03-26 23:23
    关注

    看看datachange的API

    [code="java"]dataChange Event

    Event Object Type: mx.events.FlexEvent
    property FlexEvent.type = mx.events.FlexEvent.DATA_CHANGE
    Dispatched when the data property changes.

    When you use a component as an item renderer, the data property contains an item from the dataProvider. You can listen for this event and update the component when the data property changes.

    The FlexEvent.DATA_CHANGE constant defines the value of the type property of the event object for a dataChange event.
    The properties of the event object have the following values:

    Property Value
    bubbles false
    cancelable false
    currentTarget The Object that defines the event listener that handles the event. For example, if you use myButton.addEventListener() to register an event listener, myButton is the value of the currentTarget.
    target The Object that dispatched the event; it is not always the Object listening for the event. Use the currentTarget property to always access the Object listening for the event.[/code]

    我觉得这样应该可以

    [code="java"]public function myTestDispaly(event:flash.events.Event):void{
    mx.controls.Alert.show();
    event.currentTarget.selectedItem.label + " " +
    event.currentTarget.selectedIndex;
    }
    [/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛