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.
The second one shows you a standard feed with twenty palettes. Click the "next" button to move forward.
Same example as before, but with patterns (not palettes).
This examples filters for the creator name (COLOURlover in this case).
This one shows a palette badge.
This one shows a pattern badge.
At a glance
COLOURLovers API for Flash implements all the features of the COLOURLovers API provided by colourlovers.com (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
Let me give you a simple example how to load a single palette.
span style="color: #808080; font-style: italic;">// new palettes object
// load single palette by id
// add event listeners for success
Loading palettes and patterns
Start with a new Object (
ColourLoversPatterns). There a different methods to load a set of palettes (same for patterns), e.g.
To wait for the results, just add an event listener to your object. The
Event.COMPLETE is triggered, when the feed from colourlovers.com is completely loaded and successfully parsed. For errors events, have a look in the examples.
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.badgeUrl for the first ,
result.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 - http://creativecommons.org/licenses/by-nc-sa/3.0/
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)