<?xml version="1.0" encoding="utf-8"?>
<!--Flex中如何利用dataDescriptor属性和isToggled()函数判断PopUpButton的下拉选项是否选中的例子PopUpButtonSelectableOptions.mxml-->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.controls.Menu;
import mx.events.FlexEvent;
import mx.events.MenuEvent;
private var _menu:Menu; protected function popUpButton_initializeHandler(event:FlexEvent):void
{
_menu = new Menu();
_menu.variableRowHeight = true;
_menu.dataProvider = arr;
_menu.addEventListener(MenuEvent.CHANGE,onMenuChange);
popUpButton.popUp = _menu;
} protected function onMenuChange(event:MenuEvent):void
{
switch(_menu.dataDescriptor.getType(event.item)){
case "check":
if(_menu.dataDescriptor.isToggled(event.item)){
this.styleName = "redModal";
Alert.show("\""+event.item.label+"\"was checked");
}else{
Alert.show("\""+event.item.label+"\"was not checked");
this.styleName = "greenModal";
}
break;
}
} ]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<fx:Array id="arr">
<fx:Object label="Option 1" type="check" toggled="true" />
<fx:Object label="Option 2" type="check" toggled="true" />
</fx:Array>
</fx:Declarations>
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
mx|PopUpButton {
popUpStyleName: MyCustomPopUpStyleName;
} .MyCustomPopUpStyleName {
fontWeight: normal;
textAlign: left;
} .redModal {
modalTransparencyColor: red;
modalTransparency: 0.8;
} .greenModal {
modalTransparencyColor: haloGreen;
modalTransparency: 0.8;
} </fx:Style>
<mx:PopUpButton id="popUpButton" label="Click to open..." openAlways="true" initialize="popUpButton_initializeHandler(event)" />
</s:Application>

[Flex] PopUpButton系列 —— 判断下拉列表是否选中的更多相关文章

  1. [Flex] PopUpButton系列 —— 弹出菜单的行高设置

    <?xml version="1.0" encoding="utf-8"?> <!--Flex中如何通过variableRowHeight样式 ...

  2. [Flex] PopUpButton系列 —— 控制弹出菜单的透明度、可用、可选择状态

    <?xml version="1.0" encoding="utf-8"?><!--控制弹出菜单的透明度.可用.可选择状态 PopUpButt ...

  3. [Flex] PopUpButton系列 —— 设置弹出菜单与主按钮之间的间隔

    <?xml version="1.0" encoding="utf-8"?><!--设置弹出菜单与主按钮之间的间隔 PopUpButtonPo ...

  4. [Flex] PopUpButton系列 —— 打开和关闭弹出菜单

    <?xml version="1.0" encoding="utf-8"?><!--响应打开和关闭弹出菜单的例子 PopUpButtonOpe ...

  5. [Flex] PopUpButton系列 —— 添加按钮图标

    <?xml version="1.0" encoding="utf-8"?><!--为主按钮添加默认图标 PopUpButtonIcon.mx ...

  6. [Flex] PopUpButton系列 —— 将DataGrid作为弹出内容

    <?xml version="1.0" encoding="utf-8"?> <!--Flex中如何创建一个可以弹出DataGrid作为菜单的 ...

  7. [Flex] PopUpButton系列——CornerRadius的运用

    <?xml version="1.0" encoding="utf-8"?><!--设置主按钮圆角半径 PopUpButtonCornerRa ...

  8. jquery复选框 选中事件 及其判断是否被选中

    jquery复选框 选中事件 及其判断是否被选中 (2014-07-25 14:03:54) 转载▼ 标签: jquery复选框选中事件 分类: extjs jquery   今天做了 显示和不显示密 ...

  9. ----------jqery和js如何判断checkbox是否选中 --------两个单选按钮如何选一个,且用jquery获取被选的值

    jqery和js如何判断checkbox是否选中 jquery: <div id="divId" class="divTable"> <div ...

随机推荐

  1. PHP GC垃圾回收机制之引用变量回收周期疑问

    普通的引用变量的销毁大家都知道, 当unset的时候如果refcount = 0 则认为无用, 销毁. 但是手册中提到一点会有递归引用的问题,很是奇葩 代码如下 <?php $a = 1; $a ...

  2. Mongo导出数据文件导致错误 Got signal: 6 (Aborted)解决方法

    一哥们要导出一个数据表的数据,结果导出一半,硬盘不够用,卡死了, 然后重启主机,导致mongo启动后进程自动死掉, 报错如下. Mon Oct 28 10:39:02.270 [initandlist ...

  3. Python_进程、线程及协程

    一.Python进程 IO密集型----多线程 计算密集型----多进程 1.单进程 from multiprocessing import Process def foo(i): print('你好 ...

  4. list如何remove 特别容易出错

    java中对list进行操作很频繁,特别是进行list启遍历,这些操作我们都会,也很熟悉,但是对java中list进行删除元素,remove list中的元素就不怎么熟悉了吧,可以说很陌生,是实际操作 ...

  5. VS 2010 编译安装 boost 库 -(和 jsoncpp 库共存)

    boost库的简单应用很容易,网上有很多资料,但是,如果要json 和 boost 一起使用就会出现这样那样的问题, 有时候提示找不到 “libboost_coroutine-vc100-mt-sgd ...

  6. Spring security与shiro

    shiro更轻量级,spring security过于复杂. Apache Shiro 使用手册(一)Shiro架构介绍 Spring Security笔记:Remember Me(下次自动登录)

  7. Oracle视图详解

    转载自:http://blog.itpub.net/29785807/viewspace-1270120/ 一. 视图的定义 视图(view),也称虚表, 不占用物理空间,这个也是相对概念,因为视图本 ...

  8. IntelliJ IDEA中如何设置同时打开多个文件且分行显示?

    Window→Editor Tabs→Tabs Placement→Show Tabs in Single Row 取消选中后即可在多行显示 下图为实际显示效果:  还可以自行设置打开文件窗口数(默认 ...

  9. form 转json,将form表单中的数据序列化数组后转换为Json

    页面中引用了jquery,第一想到的就是序列化,但是序列化后的表单字段为a=1&b=2这种. 这里写一个jquery的扩展方法 $.fn.serializeObject = function( ...

  10. FTP主/被动模式的原理

    ---------------------------------------------------------------------------------------------------- ...