Chapter 8. Flex for Widgets

Flex 1 was primarily a server-based technology. Flex 2 allowed us to compile SWFs in Flex Builder and then deploy them. Flex 3 gives us a new feature called “runtime shared libraries” (RSLs), which means that the generated SWFs can be much smaller than in Flex 2—so small and self-contained that we can now use Flex Builder to create real widgets for websites. These RSLs contain the code for the Flex framework and are downloaded once to the client and then cached so that they don’t have to be downloaded each time with the Flex application.

In this chapter, I’ll walk you through creating a selection of widgets that you can use as templates for your own development.

Slide Show Widget

The first widget I’ll build is a small slide show widget that reads an RSS feed from Flickr and displays the images one by one, switching out the image every two seconds. Example 8-1 shows the code for this application.

Example 8-1. Slideshow.mxml
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" paddingBottom="0" paddingLeft="0" paddingRight="0" paddingTop="0" creationComplete="flickReq.send();" backgroundAlpha="0" backgroundColor="white" backgroundGradientColors="[0xFFFFFF,0xFFFFFF]"> <mx:Script> <![CDATA[ import mx.rpc.events.ResultEvent; import mx.collections.ArrayCollection; private var images:Array = []; private var currentImage:int = 0; private function onFetchResult( event:ResultEvent ) : void { var items:ArrayCollection ...

Get Getting Started with Flex 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.