<?xml version="1.0" encoding="utf-8"?> <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 flashx.textLayout.edit.SelectionState; ]]--> </fx:Script> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <mx:ColorPicker id="cp" selectedColor="#C24141" x="40" y="34"/> <mx:VBox backgroundColor="{cp.selectedColor}" x="44" y="119" width="214" height="113"/> <mx:Label color="blue" x="242" y="40" text="selectedColor:0x{cp.selectedColor.toString(16)}"/> </s:Application>
VBox 的 backgroundColor="{cp.selectedColor}" 将随着 id 为 cp 的 colorPicker 的改变而改变