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 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决