一个警报中的选定项目

时间:2011-04-27 10:46:20

标签: flex flex3

大家好 我是新手,所以请原谅这是否是noob问题。
我有两个依赖(国家和州)和一个提交按钮的组合框 现在我想要的是在用户提交表单后它应该显示一个应该是的警告框 像

selected country is "selected item"
selected state is"selected item"

由于

3 个答案:

答案 0 :(得分:3)

以下是一个简单形式的示例

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" minWidth="955" minHeight="600">

    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;
            protected function button1_clickHandler(event:MouseEvent):void
            {
                Alert.show("Selected country is "+'"'+cm1.selectedItem+'"\n'+"Selected state is "+'"'+cm2.selectedItem+'"');
            }
        ]]>
    </mx:Script>

    <mx:ComboBox id="cm1" width="150" dataProvider="['a1','b1','c1']"/>
    <mx:ComboBox id="cm2" width="150" dataProvider="['a1a','b1b','c1c']"/>
    <mx:Button label="Submit" click="button1_clickHandler(event)"/>
</mx:Application>

答案 1 :(得分:0)

  • 要将每个组合框选定的项目作为文本使用selectedItem.labelsee here
  • 对于弹出警报,请使用Alert.showsee here
  • 对于字符串构建,请使用+运算符。
祝你好运。

答案 2 :(得分:0)

    <?xml version="1.0"?>
<!-- dpcontrols/ComboBoxEvent.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >
   <mx:Script>
      <![CDATA[
         import mx.controls.Alert;
      ]]>
   </mx:Script>

   <mx:ComboBox id="mycb"> 
      <mx:ArrayCollection>
         <mx:Object label="AL" data="Montgomery"/>
         <mx:Object label="AK" data="Juneau"/>
         <mx:Object label="AR" data="Little Rock"/>
      </mx:ArrayCollection>
   </mx:ComboBox>
     <mx:ComboBox id="mycb2"> 
      <mx:ArrayCollection>
         <mx:Object label="US" data="United States"/>
         <mx:Object label="MX" data="Mexico"/>
         <mx:Object label="IR" data="Ireland"/>
      </mx:ArrayCollection>
   </mx:ComboBox>
   <mx:Button id="button1" label="Submit" click="Alert.show('Submit Successful!  State: '+{mycb.selectedItem}+' Country:'+{mycb2.selectedItem}, 'Alert Box', mx.controls.Alert.OK);"/>
" width="100"/>
</mx:Application>