Skip to content
Dec 23 / Peter deHaan

Changing the data provider on the ColorPicker control in Flash using ActionScript 3.0

The following example shows how you can set the data provider for the Flash ActionScript 3.0 ColorPicker component by setting the colors property.

Full code after the jump.

// ActionScript 3.0
/* Requires:
 * - ColorPicker control in Flash library
 */
var arr:Array = [0x000000, 0x110000, 0x220000, 0x330000, 
                 0x440000, 0x550000, 0x660000, 0x770000, 
                 0x880000, 0x990000, 0xAA0000, 0xBB0000, 
                 0xCC0000, 0xDD0000, 0xEE0000, 0xFF0000, // red
 
                 0x000000, 0x111111, 0x222222, 0x333333, 
                 0x444444, 0x555555, 0x666666, 0x777777,
                 0x888888, 0x999999, 0xAAAAAA, 0xBBBBBB,
                 0xCCCCCC, 0xDDDDDD, 0xEEEEEE, 0xFFFFFF]; //white
 
var colorPicker:ColorPicker = new ColorPicker();
colorPicker.colors = arr;
colorPicker.setStyle("columnCount", 16);
colorPicker.move(10, 10);
addChild(colorPicker);
Leave a Comment