Flex developers interested in working with CRX or CQ5 might want to have a look at a package I have recently uploaded to the public section of the Package Share. It is called "Flexling" and contains:
- an Actionscript library for read and write access to CRX (as well as search)
- a help file and API docs for the library
- an example Flex application
Preview of the package:
After installation of the package point your browser to localhost:(port)/apps/flexling/docs/flexling.html where the introductory document is located.
How it works
The library basically wraps the Sling http API into an Actionscript object com.day.sling.Sling. There are three methods for reading and searching content: getContent (synchronous), loadContent (asynchronous) and search (asynchronous). Under the hood these leverage the json rendering of JCR content that Sling provides. In a similar fashion the methods saveContent and removeContent wrap the SlingPostServlet's functionality for writing to the repository (both are asynchronous). All asynchronous methods dispatch com.day.sling.SlingEvent events when done (inherited from flash.events.Event).
The method getContent exists basically for educational purposes - loadContent would be sufficient to read from the repository. getContent shows how to leverage the browser's XHR object for reading from the repository (using flash.external.ExternalInterface) while loadContent uses the flash.net.URLLoader.
This is exactly the approach taken by the Flex-based CQ5 standard slideshow component (see screenshot below). It ships with the complete Flex source code in the repository at /libs/foundation/components/slideshow/src.
Kudos to Josh Oransky who collaborated with me on the Flexling package.