// Copyright 2007. Adobe Systems Incorporated. All Rights Reserved. package fl.controls { import fl.core.UIComponent; import fl.core.InvalidationType; import fl.controls.BaseButton; import fl.controls.TextInput; import fl.controls.TextArea; import fl.events.ComponentEvent; import fl.events.student_ar_fl_controls_ColorPickerEvent; import fl.managers.IFocusManager; import fl.managers.IFocusManagerComponent; import flash.events.MouseEvent; import flash.events.Event; import flash.events.KeyboardEvent; import flash.events.FocusEvent; import flash.display.DisplayObject; import flash.display.Graphics; import flash.display.Sprite; import flash.geom.ColorTransform; import flash.geom.Point; import flash.geom.Rectangle; import flash.text.TextField; import flash.text.TextFieldType; import flash.text.TextFormat; import flash.ui.Keyboard; import flash.system.IME; //-------------------------------------- // Events //-------------------------------------- /** * Dispatched when the user opens the color palette. * * @eventType flash.events.Event.OPEN * * @includeExample examples/student_ar_fl_controls_ColorPicker.open.2.as -noswf * * @see #event:close * @see #open() * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ [Event(name="open", type="flash.events.Event")] /** * Dispatched when the user closes the color palette. * * @eventType flash.events.Event.CLOSE * * @see #event:open * @see #close() * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ [Event(name="close", type="flash.events.Event")] /** * Dispatched when the user clicks a color in the palette. * * @includeExample examples/student_ar_fl_controls_ColorPicker.hexValue.1.as -noswf * * @eventType fl.events.student_ar_fl_controls_ColorPickerEvent.CHANGE * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ [Event(name="change", type="fl.events.student_ar_fl_controls_ColorPickerEvent")] /** * Dispatched when the user rolls over a swatch in the color palette. * * @eventType fl.events.student_ar_fl_controls_ColorPickerEvent.ITEM_ROLL_OVER * * @see #event:itemRollOut * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ [Event(name="itemRollOver", type="fl.events.student_ar_fl_controls_ColorPickerEvent")] /** * Dispatched when the user rolls out of a swatch in the color palette. * * @eventType fl.events.student_ar_fl_controls_ColorPickerEvent.ITEM_ROLL_OUT * * @see #event:itemRollOver * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ [Event(name="itemRollOut", type="fl.events.student_ar_fl_controls_ColorPickerEvent")] /** * Dispatched when the user presses the Enter key after editing the internal text field of the student_ar_fl_controls_ColorPicker component. * * @eventType fl.events.student_ar_fl_controls_ColorPickerEvent.ENTER * * @includeExample examples/student_ar_fl_controls_ColorPicker.enter.1.as -noswf * * @see #editable * @see #textField * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ [Event(name="enter", type="fl.events.student_ar_fl_controls_ColorPickerEvent")] //-------------------------------------- // Styles //-------------------------------------- /** * Defines the padding that appears around each swatch in the color palette, in pixels. * * @default 1 * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ [Style(name="swatchPadding", type="Number", format="Length")] /** * The class that provides the skin for a disabled button in the student_ar_fl_controls_ColorPicker. * * @default student_ar_fl_controls_ColorPicker_disabledSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0 * * @internal [kenos] Changed description from "Disabled skin for the student_ar_fl_controls_ColorPicker button" to the current. * Is this correct? */ [Style(name="disabledSkin", type="Class")] /** * The padding that appears around the color TextField, in pixels. * * @default 3 * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ [Style(name="textPadding", type="Number", format="Length")] /** * The class that provides the skin for the color well when the pointing device rolls over it. * * @default student_ar_fl_controls_ColorPicker_overSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ [Style(name="overSkin", type="Class")] /** * The padding that appears around the group of color swatches, in pixels. * * @default 5 * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ [Style(name="backgroundPadding", type="Number", format="Length")] /** * The class that provides the skin for the color well when it is filled with a color. * * @default student_ar_fl_controls_ColorPicker_colorWell * * @langversion 3.0 * @playerversion Flash 9.0.28.0 * */ [Style(name="colorWell", type="Class")] /** * The class that provides the skin for the student_ar_fl_controls_ColorPicker button when it is in the down position. * * @default student_ar_fl_controls_ColorPicker_downSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0 * * @internal [kenos] Description was "Down skin for the student_ar_fl_controls_ColorPicker button." Is the revised description correct? */ [Style(name="downSkin", type="Class")] /** * The class that provides the background for the text field of the student_ar_fl_controls_ColorPicker component. * * @default student_ar_fl_controls_ColorPicker_textFieldSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ [Style(name="textFieldSkin", type="Class")] /** * The class that provides the background of the palette that appears in the student_ar_fl_controls_ColorPicker component. * * @default student_ar_fl_controls_ColorPicker_backgroundSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ [Style(name="background", type="Class")] /** * The class that provides the skin which is used to draw the swatches contained in the student_ar_fl_controls_ColorPicker component. * * @default student_ar_fl_controls_ColorPicker_swatchSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ [Style(name="swatchSkin", type="Class")] /** * The class that provides the skin which is used to highlight the currently selected color. * * @default student_ar_fl_controls_ColorPicker_swatchSelectedSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ [Style(name="swatchSelectedSkin", type="Class")] /** * The width of each swatch, in pixels. * * @default 10 * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ [Style(name="swatchWidth", type="Number", format="Length")] /** * The height of each swatch, in pixels. * * @default 10 * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ [Style(name="swatchHeight", type="Number", format="Length")] /** * The number of columns to be drawn in the student_ar_fl_controls_ColorPicker color palette. * * @default 18 * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ [Style(name="columnCount", type="Number", format="Length")] /** * The class that provides the skin for the student_ar_fl_controls_ColorPicker button when it is in the up position. * * @default student_ar_fl_controls_ColorPicker_upSkin * * @langversion 3.0 * @playerversion Flash 9.0.28.0 * * @internal [kenos] The previous description was "Up skin for the student_ar_fl_controls_ColorPicker button." Is the revised description * correct? */ [Style(name="upSkin", type="Class")] /** * @copy fl.controls.LabelButton#style:embedFonts * * @default false * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ [Style(name="embedFonts", type="Boolean")] //-------------------------------------- // Class description //-------------------------------------- /** * The student_ar_fl_controls_ColorPicker component displays a list of one or more swatches * from which the user can select a color. * *
By default, the component displays a single swatch of color on a * square button. When the user clicks this button, a panel opens to * display the complete list of swatches.
* * @includeExample examples/student_ar_fl_controls_ColorPickerExample.as * * @see fl.events.student_ar_fl_controls_ColorPickerEvent student_ar_fl_controls_ColorPickerEvent * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public class student_ar_fl_controls_ColorPicker extends UIComponent implements IFocusManagerComponent { /** * A reference to the internal text field of the student_ar_fl_controls_ColorPicker component. * * @see #showTextField * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public var textField:TextField; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var customColors:Array; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public static var defaultColors:Array; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var colorHash:Object; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var paletteBG:DisplayObject; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var selectedSwatch:Sprite; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var _selectedColor:uint; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var rollOverColor:int = -1; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var _editable:Boolean = true; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var _showTextField:Boolean = true; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var isOpen:Boolean = false; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var doOpen:Boolean = false; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var swatchButton:BaseButton; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var colorWell:DisplayObject; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var swatchSelectedSkin:DisplayObject; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var palette:Sprite; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var textFieldBG:DisplayObject; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var swatches:Sprite; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var swatchMap:Array; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var currRowIndex:int; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected var currColIndex:int; /** * @private * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ private static var defaultStyles:Object = {upSkin:"student_ar_fl_controls_ColorPicker_upSkin", disabledSkin:"student_ar_fl_controls_ColorPicker_disabledSkin", overSkin:"student_ar_fl_controls_ColorPicker_overSkin", downSkin:"student_ar_fl_controls_ColorPicker_downSkin", colorWell:"student_ar_fl_controls_ColorPicker_colorWell", swatchSkin:"student_ar_fl_controls_ColorPicker_swatchSkin", swatchSelectedSkin:"student_ar_fl_controls_ColorPicker_swatchSelectedSkin", swatchWidth:10, swatchHeight:10, columnCount:18, swatchPadding:1, textFieldSkin:"student_ar_fl_controls_ColorPicker_textFieldSkin", textFieldWidth:null, textFieldHeight:null, textPadding:3, background:"student_ar_fl_controls_ColorPicker_backgroundSkin", backgroundPadding:5, textFormat:null, focusRectSkin:null, focusRectPadding:null, embedFonts:false }; /** * @copy fl.core.UIComponent#getStyleDefinition() * * @includeExample ../core/examples/UIComponent.getStyleDefinition.1.as -noswf * * @see fl.core.UIComponent#getStyle() UIComponent.getStyle() * @see fl.core.UIComponent#setStyle() UIComponent.setStyle() * @see fl.managers.StyleManager StyleManager * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public static function getStyleDefinition():Object { return defaultStyles; } /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected static const POPUP_BUTTON_STYLES:Object = { disabledSkin:"disabledSkin", downSkin:"downSkin", overSkin:"overSkin", upSkin:"upSkin" }; /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ protected static const SWATCH_STYLES:Object = { disabledSkin:"swatchSkin", downSkin:"swatchSkin", overSkin:"swatchSkin", upSkin:"swatchSkin" }; /** * Creates an instance of the student_ar_fl_controls_ColorPicker class. * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public function student_ar_fl_controls_ColorPicker() { super(); } [Inspectable(type="Color",defaultValue="#000000")] /** * Gets or sets the swatch that is currently highlighted in the palette of the student_ar_fl_controls_ColorPicker component. * * @default 0x000000 * * @includeExample examples/student_ar_fl_controls_ColorPicker.selectedColor.1.as -noswf * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public function get selectedColor():uint { if (colorWell == null) { return 0; } return colorWell.transform.colorTransform.color; } /** * @private (setter) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public function set selectedColor(value:uint):void { if (!_enabled) { return; } _selectedColor = value; rollOverColor = -1; currColIndex = currRowIndex = 0; // Set the color value immediately to avoid invalidation. var ct:ColorTransform = new ColorTransform(); ct.color = value; setColorWellColor(ct); invalidate(InvalidationType.DATA); } /** * Gets the string value of the current color selection. * * @includeExample examples/student_ar_fl_controls_ColorPicker.hexValue.1.as -noswf * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public function get hexValue():String { if (colorWell == null) { return colorToString(0); } return colorToString(colorWell.transform.colorTransform.color); } [Inspectable(defaultValue=true, verbose=1)] /** * @copy fl.core.UIComponent#enabled * * @default true * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ override public function get enabled():Boolean { return super.enabled; } /** * @private (setter) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ override public function set enabled(value:Boolean):void { super.enabled = value; if (!value) { close(); } swatchButton.enabled = value; } /** * Gets or sets a Boolean value that indicates whether the internal text field of the * student_ar_fl_controls_ColorPicker component is editable. A value oftrue
indicates that
* the internal text field is editable; a value of false
indicates
* that it is not.
*
* @default true
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function get editable():Boolean {
return _editable;
}
/**
* @private (setter)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function set editable(value:Boolean):void {
_editable = value;
invalidate(InvalidationType.STATE);
}
[Inspectable(defaultValue=true)]
/**
* Gets or sets a Boolean value that indicates whether the internal text field
* of the student_ar_fl_controls_ColorPicker component is displayed. A value of true
indicates
* that the internal text field is displayed; a value of false
indicates
* that it is not.
*
* @default true
*
* @includeExample examples/student_ar_fl_controls_ColorPicker.showTextField.1.as -noswf
*
* @see #textField
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function get showTextField():Boolean {
return _showTextField;
}
/**
* @private (setter)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function set showTextField(value:Boolean):void {
invalidate(InvalidationType.STYLES);
_showTextField = value;
}
/**
* Gets or sets the array of custom colors that the student_ar_fl_controls_ColorPicker component
* provides. The student_ar_fl_controls_ColorPicker component draws and displays the colors that are
* described in this array.
*
* Note: The maximum number of colors that the student_ar_fl_controls_ColorPicker * component can display is 1024.
* *By default, this array contains 216 autogenerated colors.
* * @includeExample examples/student_ar_fl_controls_ColorPicker.colors.1.as -noswf * * @langversion 3.0 * @playerversion Flash 9.0.28.0 * */ public function get colors():Array { return (customColors != null)?customColors:student_ar_fl_controls_ColorPicker.defaultColors; } /** * @private (setter) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public function set colors(value:Array):void { customColors = value; invalidate(InvalidationType.DATA); } /** * @copy fl.controls.TextArea#imeMode * * @see flash.system.IMEConversionMode IMEConversionMode * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public function get imeMode():String { return _imeMode; } /** * @private (protected) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public function set imeMode(value:String):void { _imeMode = value; } /** * Shows the color palette. Calling this method causes theopen
* event to be dispatched. If the color palette is already open or disabled,
* this method has no effect.
*
* @includeExample examples/student_ar_fl_controls_ColorPicker.open.2.as -noswf
*
* @see #close()
* @see #event:open
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function open():void {
if (!_enabled) {
return;
}
doOpen = true;
var fm:IFocusManager = focusManager;
if (fm) {
fm.defaultButtonEnabled = false;
}
invalidate(InvalidationType.STATE);
}
/**
* Hides the color palette. Calling this method causes the close
* event to be dispatched. If the color palette is already closed or disabled,
* this method has no effect.
*
* @see #event:close
* @see #open()
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function close():void {
if (isOpen) {
stage.removeChild(palette);
isOpen = false;
dispatchEvent(new Event(Event.CLOSE));
}
var fm:IFocusManager = focusManager;
if (fm) {
fm.defaultButtonEnabled = true;
}
removeStageListener();
cleanUpSelected();
}
/**
* @private
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
private function addCloseListener(event:Event) {
removeEventListener(Event.ENTER_FRAME, addCloseListener);
if (!isOpen) {
return;
}
addStageListener();
}
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected function onStageClick(event:MouseEvent):void {
if (!contains(event.target as DisplayObject) && !palette.contains(event.target as DisplayObject)) {
selectedColor = _selectedColor;
close();
}
}
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected function setStyles():void {
var bg:DisplayObject = colorWell;
var colorWellStyle:Object = getStyleValue("colorWell");
if (colorWellStyle != null) {
colorWell = getDisplayObjectInstance(colorWellStyle) as DisplayObject;
}
addChildAt(colorWell, getChildIndex(swatchButton));
copyStylesToChild(swatchButton, POPUP_BUTTON_STYLES);
swatchButton.drawNow();
if (bg != null && contains(bg) && bg != colorWell) {
removeChild(bg);
}
}
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected function cleanUpSelected():void {
if (swatchSelectedSkin && palette.contains(swatchSelectedSkin)) {
palette.removeChild(swatchSelectedSkin);
}
}
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected function onPopupButtonClick(event:MouseEvent):void {
if (isOpen) {
close();
} else {
open();
}
}
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
override protected function draw():void {
if (isInvalid(InvalidationType.STYLES, InvalidationType.DATA)) {
setStyles();
drawPalette();
setEmbedFonts();
invalidate(InvalidationType.DATA, false);
invalidate(InvalidationType.STYLES, false);
}
if (isInvalid(InvalidationType.DATA)) {
drawSwatchHighlight();
setColorDisplay();
}
if (isInvalid(InvalidationType.STATE)) {
setTextEditable();
if (doOpen) {
doOpen = false;
showPalette();
}
colorWell.visible = enabled;
}
if (isInvalid(InvalidationType.SIZE, InvalidationType.STYLES)) {
swatchButton.setSize(width, height);
swatchButton.drawNow();
colorWell.width = width;
colorWell.height = height;
}
super.draw();
}
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected function showPalette():void {
if (isOpen) {
positionPalette();
return;
}
addEventListener(Event.ENTER_FRAME, addCloseListener, false, 0, true);
stage.addChild(palette);
isOpen = true;
positionPalette();
dispatchEvent(new Event(Event.OPEN));
stage.focus = textField; // This is causing some issues.
// Highlight the appropriate swatch.
var swatch:Sprite = selectedSwatch;
if (swatch == null) {
swatch = findSwatch(_selectedColor);
}
setSwatchHighlight(swatch);
}
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected function setEmbedFonts():void {
var embed:Object = getStyleValue('embedFonts');
if (embed != null) {
textField.embedFonts = embed;
}
}
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected function drawSwatchHighlight():void {
cleanUpSelected();
var skin:Object = getStyleValue("swatchSelectedSkin");
var swatchPadding:Number = getStyleValue("swatchPadding") as Number;
if (skin != null) {
swatchSelectedSkin = getDisplayObjectInstance(skin);
swatchSelectedSkin.x = 0;
swatchSelectedSkin.y = 0;
swatchSelectedSkin.width = (getStyleValue("swatchWidth") as Number) + 2;
swatchSelectedSkin.height = (getStyleValue("swatchHeight") as Number) + 2;
}
}
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected function drawPalette():void {
if (isOpen) {
stage.removeChild(palette);
}
palette = new Sprite();
drawTextField();
drawSwatches();
drawBG();
}
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected function drawTextField():void {
if (!showTextField) {
return;
}
var padding:Number = getStyleValue("backgroundPadding") as Number;
var textPadding:Number = getStyleValue("textPadding") as Number;
// Add the TextField background
textFieldBG = getDisplayObjectInstance(getStyleValue("textFieldSkin"));
if (textFieldBG != null) {
palette.addChild(textFieldBG);
textFieldBG.x = textFieldBG.y = padding;
}
// Format the text field
var uiStyles:Object = UIComponent.getStyleDefinition();
var defaultTF:TextFormat = enabled ? uiStyles.defaultTextFormat as TextFormat : uiStyles.defaultDisabledTextFormat as TextFormat;
textField.setTextFormat(defaultTF);
var tf:TextFormat = getStyleValue("textFormat") as TextFormat;
if (tf != null) {
textField.setTextFormat(tf);
} else {
tf = defaultTF;
}
textField.defaultTextFormat = tf;
setEmbedFonts();
textField.restrict = "A-Fa-f0-9#";
textField.maxChars = 6;
palette.addChild(textField);
textField.text = " #888888 ";
textField.height = textField.textHeight + 3;
textField.width = textField.textWidth + 3;
textField.text = "";
textField.x = textField.y = padding + textPadding;
textFieldBG.width = textField.width + (textPadding*2);
textFieldBG.height = textField.height + (textPadding*2);
setTextEditable();
}
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected function drawSwatches():void {
var padding:Number = getStyleValue("backgroundPadding") as Number;
var swatchY:Number = (showTextField ? textFieldBG.y + textFieldBG.height + padding : padding);
swatches = new Sprite();
palette.addChild(swatches);
swatches.x = padding;
swatches.y = swatchY;
var cols:uint = getStyleValue("columnCount") as uint;
var pad:uint = getStyleValue("swatchPadding") as uint;
var w:Number = getStyleValue("swatchWidth") as Number;
var h:Number = getStyleValue("swatchHeight") as Number;
colorHash = {};
swatchMap = [];
var l:uint = Math.min(1024, colors.length);
var rc:int = -1;
for (var i:uint=0; i