COLOURLovers API for Flash

COLOURlovers is a really cool community for sharing colors. You can find hundreds of thousands of color palettes and patterns. There’s also a nice RSS/XML API (COLOURlovers API) to access the content. I really like those kind of flash-friendly APIs, so I couldn’t resist to write some Flash classes. With COLOURlovers API for Flash you can easily use the functions of the XML API in ActionScript.


Let’s start with some examples:

The first examples load a single palette by an id.

[kml_flashembed movie=“/wp-content/uploads/2008/09/01-load-single-palette.swf“ width=“500″ height=“350″ /]

The second one shows you a standard feed with twenty palettes. Click the „next“ button to move forward.

[kml_flashembed movie=“/wp-content/uploads/2008/09/02-load-palettes.swf“ width=“500″ height=“350″ /]

Same example as before, but with patterns (not palettes).

[kml_flashembed movie=“/wp-content/uploads/2008/09/02-load-patterns.swf“ width=“500″ height=“350″ /]


This examples filters for the creator name (COLOURlover in this case).

[kml_flashembed movie=“/wp-content/uploads/2008/09/03-load-palettes-parameters.swf“ width=“500″ height=“350″ /]

This one shows a palette badge.

[kml_flashembed movie=“/wp-content/uploads/2008/09/04-palettes-badge.swf“ width=“500″ height=“350″ /]

This one shows a pattern badge.

[kml_flashembed movie=“/wp-content/uploads/2008/09/05-pattern-badge.swf“ width=“500″ height=“350″ /]

At a glance

COLOURLovers API for Flash implements all the features of the COLOURLovers API provided by (only for palettes and patterns at the moment). COLOURLovers API for Flash at a glance:

  • Written in ActionScript 3
  • You can use it with Flash and Flex
  • Load all the available feed types provided by COLOURLovers
  • Access to all properties of the palettes and patterns
  • Filter/Search queries for lovers, colors, etc.
  • Documentation included
  • Under Creative Commons License

Code example

Let me give you a simple example how to load a single palette.
import com.florianplag.*;

// new palettes object
var myPalettes:ColourLoversPalettes = new ColourLoversPalettes();

// load single palette by id

// add event listeners for success
myPalettes.addEventListener (Event.COMPLETE, onComplete);

function onComplete(evt:Event):void {

trace („title: “ + myPalettes.result[0].title );

trace (myPalettes.result[0].colors[0]);
trace (myPalettes.result[0].colors[1]);
trace (myPalettes.result[0].colors[2]);
trace (myPalettes.result[0].colors[3]);
trace (myPalettes.result[0].colors[4]);
That’s it!

Loading palettes and patterns

Start with a new Object (ColourLoversPalettes or ColourLoversPatterns). There a different methods to load a set of palettes (same for patterns), e.g. loadPalettes, loadPalettesNew, loadPalettesTop and loadPalettesRandom.

To wait for the results, just add an event listener to your object. The Event.COMPLETE is triggered, when the feed from is completely loaded and successfully parsed. For errors events, have a look in the examples.

The result

The result is always stored in an array called result (for instance myPalettes.result). For each palette/pattern that is delivered, you just have to set the number in the square brackets (e.g. result[0].badgeUrl for the first , result[1].badgeUrl for the second, …) to access the different palettes/patterns. The number of items in the result can be found out using the method myPalettes.result (e.g. 20, if there are 20 palettes in the feed).


Each result has the complete set of properties, that is provided by the COLOURlovers API (id, title, description, numView, etc.). For an overview, please have a look in the documentation.

Feedback, Bugs, Improvements

This is the first version. I havent’t had the time to check all properties in details. If you find bugs, please leave a comment. The ActionScript could also be improved a little because there’s some redundancy between the patterns and palettes code.


Attribution-Noncommercial-Share Alike –
If you would like to use the API in ways outside of this license please contact me for permission. Please consider the license of COLOURLovers API, too.

Download: COLOURLovers API for Flash 0.1 (Flash classes, examples, documentation)

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert