现在的位置: 首页 > 综合 > 正文

flex中的颜色选择器ColorPicker总结

2018年01月29日 ⁄ 综合 ⁄ 共 857字 ⁄ 字号 评论关闭

颜色选择器

标签创建

<mx:ColorPicker id="colorPicker" x="292" y="10"
change="colorPicker_changeHandler(event)" selectedColor="#EEEEEE"/>

as代码动态创建

private function CreateColorPicker(_Id:String,_X:Number, _Y:Number):ColorPicker{
var colorPicker:ColorPicker=new ColorPicker();
colorPicker.id=_Id;      
colorPicker.x=_X;       
colorPicker.y=_Y;   
colorPicker.addEventListener(ColorPickerEvent.CHANGE,selectColorPicker); //参考事件说明
return colorPicker;      
}
//选择事件
private function selectColorPicker(event:ColorPickerEvent):void{
Alert.show(event.target.selectedColor.toString(16));        // 输出结果类似ccccc

Alert.show(event.target.id);  // event.target.id是当前颜色选择器的id值
}

事件说明

ColorPickerEvent.CHANGE:用户单击 ColorPicker 组件中的另一种颜色时调度。 
ColorPickerEvent.ENTER:用户在 ColorPicker 组件的文本字段中输入值以后按 Enter 键时调度。 
ColorPickerEvent.ITEM_ROLL_OUT:在设备指针从 ColorPicker 组件中的颜色单元格移出时调度。 
ColorPickerEvent.ITEM_ROLL_OVER:在设备指针移到 ColorPicker 组件中的颜色单元格上方时调度。

抱歉!评论已关闭.