Wiring up a Catalyst Project

A designer buddy of mine (Paul Ramos) has been taking a look at Catalyst and put together a quick little app to try out the tool from a design perspective. He let me have the resulting project to try wiring it up and produce a working app.

The app was a basic Flickr search with an initial search box and a transition to the pictures returned for it. Catalyst created a project with some placeholder images so when I imported it to FlashBuilder, it looked like this:

Catalyst produced Flickr app

Catalyst produced Flickr app

The main MXML file is under src in the default package and it contains andArrayCollection of objects created to provide the placeholders you see above. I basically followed the steps outlined in Lee Brimelow’s tutorial I linked to in my prior Catalyst post to delete this and replace the data binding for the list with an ArrayCollection I declared to contain the results of the Flickr search.  The HTTPService needs to be declared within an fx:Declarations block for Flex4 but is otherwise the same.  There’s a Flickr app on the Adobe site so I used that as the basis for how to talk to Flickr. I found the relevant button click handler and put the HTTP service  send call in that, added a mouseOver handler for the text input to clear the text prompt (more on that later) and that was pretty much it for the main file. The end result looks like this (well with better formatting):

<?xml version=’1.0′ encoding=’UTF-8′?>
<s:Application xmlns:mx=”library://ns.adobe.com/flex/halo”
width=”1000″ height=”600″ backgroundColor=”#ffffff”>

<s:Transition fromState=”Page1″ toState=”Page2″ autoReverse=”true”>
<s:Parallel target=”{list1}”>
<s:Fade duration=”750″/>
<s:Parallel target=”{button2}”>
<s:Fade duration=”750″/>

<s:Transition fromState=”Page2″ toState=”Page1″ autoReverse=”true”>
<s:Parallel target=”{list1}”>
<s:Parallel target=”{button2}”>


import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;
import mx.collections.ArrayCollection;

private var ac:ArrayCollection;

private var firstTimeIn:Boolean=true;

protected function Button_click():void
var params:Object = new Object();
params.format = ‘rss_200_enc’;
params.tags = textInput1.text;

protected function Button_click_1():void
var state:String = currentState;
if ( state == ‘Page2′ ) {

protected function photoService_resultHandler(event:ResultEvent):void
ac=photoService.lastResult.rss.channel.item as ArrayCollection;

private function photoFaultHandler(event:FaultEvent):void
Alert.show(“Oops! Can’t seem to get photos”,”Error”);

private function clearTextInput():void
if (firstTimeIn){
textInput1.text=” “;


<s:HTTPService id=”photoService” result=”photoService_resultHandler(event)”

<s:State name=”Page1″ th:color=”0xcc0000″/>
<s:State name=”Page2″/>

<s:BitmapImage source=”@Embed(‘/assets/flickr_app_template/Background.png’)” resizeMode=”scale” d:userLabel=”Background” id=”bitmapimage1″/>

<fx:DesignLayer d:userLabel=”Input Field”>
<s:TextInput x=”145″ y=”43″ skinClass=”components.TextInput1″
text=”Input Your Search Text Here” id=”textInput1″ mouseOver=”clearTextInput()”/>

<s:Button x=”656″ y=”32″ skinClass=”components.Button2″ id=”button1″ click=”Button_click()”/>

<s:List x=”144″ skinClass=”components.DataList1″ id=”list1″ y=”152″ visible.Page1=”false” dataProvider=”{ac}”/>

<s:Button includeIn=”Page2″ x=”587″ y=”124″ skinClass=”components.Button3″ label=”Click here to return to front” id=”button2″ click=”Button_click_1()”/>


The next part to work on is the image rendering which is under the components package in the RepeatedItem1 file. Here I switched out the s:BitmapImage for a standard mx:Image that would deal with the data returned by Flickr and change the data binding to point to the relevant element of the data. The S:RichText binding was updated for it’s data element too.  The user label is something Catalyst uses so we can leave that alone. The end result for that (again with better formatting) is:

<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:s="library://ns.adobe.com/flex/spark" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:d="http://ns.adobe.com/fxg/2008/dt" xmlns:mx="library://ns.adobe.com/flex/halo">
<s:State name="normal"/>
<s:State name="hovered"/>
<s:State name="selected"/>
<s:Rect d:userLabel="Item Highlight" width="115" height="128" alpha.normal="0" alpha.hovered="0.4" alpha.selected="0.8">
<s:SolidColor color="0xCED7EE"/>
<mx:Image source="{data.thumbnail.url}" d:userLabel="Shape 4" id="bitmapimage3"/>
<s:RichText d:userLabel="This is where the
Descriptive link goes" fontFamily="Calibri" color="0x000000" fontSize="12" trackingRight="0.5" kerning="off" textAlign="center" whiteSpaceCollapse="preserve" id="richtext1" x="3" y="101" text="{data.credit}">

That was it – not too much to it really. I initially tried to use a click handler to clear the prompt text but that would clear it and lose the text cursor so you couldn’t  enter anything. I tried it back in a Flex3 Halo component and it worked fine there so this may be a Flex 4 “feature”. The final working app looks like this:

Fully wired up Flickr app

Fully wired up Flickr app


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: