The following example shows how you can detect when the selected color in a Flash ActionScript 3.0 ColorPicker component by listening for the change event (using the static ColorPickerEvent.CHANGE constant).
Full code after the jump.
// ActionScript 3.0 /* Requires: * - ColorPicker control in the Flash library */ import fl.controls.ColorPicker; import fl.events.ColorPickerEvent; var bg:Sprite = new Sprite(); bg.graphics.beginFill(0x000000); bg.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); bg.graphics.endFill(); addChild(bg); var colorPicker:ColorPicker = new ColorPicker(); colorPicker.addEventListener(ColorPickerEvent.CHANGE, colorPicker_change); colorPicker.move(10, 10); addChild(colorPicker); function colorPicker_change(evt:ColorPickerEvent):void { trace(evt.color, colorPicker.textField.text); bg.graphics.beginFill(evt.color); // 16711680 #ff0000 bg.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); bg.graphics.endFill(); }
{ 0 comments… add one now }