课程表

Flex课程

工具箱
速查手册

Flex ColorPicker控件

当前位置:免费教程 » 软件/图像 » Flex

介绍

ColorPicker控件为用户提供了从样本列表中选择颜色的方法。默认模式是在方形按钮中显示单个样本。

当用户单击色板按钮时,将显示色板面板,并显示整个色板列表。

类声明

以下是 mx.controls.ColorPicker 类的声明:

  1. public class ColorPicker
  2. extends ComboBase

公共财产

S.N.属性和描述
1

colorField:String

dataProvider数组的对象中的字段名称,指定样本面板显示的颜色的十六进制值。

2

labelField:String

dataProvider数组的对象中的字段名称,其中包含要在SwatchPanel对象文本框中显示为标签的文本。

3

selectedColor:uint

SwatchPanel对象中当前选定颜色的值。

4

selectedIndex:int

[override] SwatchPanel对象中所选项的dataProvider中的索引。

5

showTextField:Boolean

指定是否显示显示颜色标签或十六进制颜色值的文本框。

受保护的属性

S.N.属性和描述
1

swatchStyleFilters:Object

[只读]从ColorPicker传递到预览色板的样式集。

公共方法

S.N.方法和描述
1

ColorPicker()

构造函数。

2

close(trigger:Event = null):void

隐藏下拉SwatchPanel对象。

3

open():void

显示下拉SwatchPanel对象,该对象显示用户可以选择的颜色。

事件

S.N.事件和描述
1

显示下拉SwatchPanel对象,该对象显示用户可以选择的颜色。...

当所选颜色因用户交互而更改时分派。

2

close

样本面板关闭时分派。

3

enter

如果ColorPicker可编辑属性设置为true,并且用户在键入十六进制颜色值后按Enter键,则分派。

4

itemRollOut

当用户将鼠标从SwatchPanel对象中的样本滚出时分派。

5

itemRollOver

当用户将鼠标悬停在SwatchPanel对象中的样本上时分派。

6

open

在颜色样本面板打开时分派。

继承的方法

此类继承以下类中的方法:

  • mx.controls.comboBase

  • mx.core.UIComponent

  • mx.core.FlexSprite

  • flash.display.Sprite

  • flash.display.DisplayObjectContainer

  • flash.display.InteractiveObject

  • flash.display.DisplayObject

  • flash.events.EventDispatcher

  • Object

Flex ColorPicker控件示例

让我们按照以下步骤,通过创建测试应用程序来检查Flex应用程序中ColorPicker控件的使用情况:

步骤描述
1 Flex - 创建应用程序章节中所述,在包 com.tutorialspoint.client 下创建名为 HelloWorld 的项目。
2修改 HelloWorld.mxml ,如下所述。 保持文件的其余部分不变。
3编译并运行应用程序,以确保业务逻辑按照要求工作。

以下是修改后的mxml文件 src / com.tutorialspoint / HelloWorld.mxml 的内容。

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
  3. xmlns:s="library://ns.adobe.com/flex/spark"
  4. xmlns:mx="library://ns.adobe.com/flex/mx"
  5. width="100%" height="100%" minWidth="500" minHeight="500"
  6. >
  7. <fx:Style source="/com/tutorialspoint/client/Style.css"/>
  8. <s:BorderContainer width="550" height="400" id="mainContainer"
  9. styleName="container">
  10. <s:VGroup width="100%" height="100%" gap="50"
  11. horizontalAlign="center" verticalAlign="middle">
  12. <s:Label id="lblHeader" text="Form Controls Demonstration"
  13. fontSize="40" color="0x777777" styleName="heading"/>
  14. <s:Panel id="colorPickerPanel"
  15. backgroundColor="{colorPicker.selectedColor}"
  16. title="Using ColorPicker" width="420" height="200">
  17. <s:layout>
  18. <s:HorizontalLayout gap="10" verticalAlign="middle"
  19. horizontalAlign="center"/>
  20. </s:layout>
  21. <s:Label width="150" color="black"
  22. text="Select background color: " fontWeight="bold"/>
  23. <mx:ColorPicker id="colorPicker"
  24. showTextField="true" selectedColor="0xFFFFFF"/>
  25. </s:Panel>
  26. </s:VGroup>
  27. </s:BorderContainer>
  28. </s:Application>

准备好所有更改后,让我们以正常模式编译和运行应用程序,就像在 Flex - 创建应用程序中一样 章节。 如果一切顺利,您的应用程序,这将产生以下结果:[在线试用]

Flex ColorPicker Control
转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号