<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Flex Gallery</title>
	
	<link>http://www.flexgallery.com</link>
	<description>Mobile and Web Applications and Samples</description>
	<lastBuildDate>Wed, 27 Jul 2011 18:14:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/FlexGallery" /><feedburner:info uri="flexgallery" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Connecting to the Flickr REST endpoint with DCD</title>
		<link>http://feedproxy.google.com/~r/FlexGallery/~3/2poVqAx2-qc/</link>
		<comments>http://www.flexgallery.com/2011/07/connecting-to-the-flickr-rest-endpoin-with-dcd/#comments</comments>
		<pubDate>Wed, 27 Jul 2011 17:34:16 +0000</pubDate>
		<dc:creator>Shashwati Keith</dc:creator>
				<category><![CDATA[Flickr]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">http://www.flexgallery.com/?p=195</guid>
		<description><![CDATA[If you are curious about how to connect directly to the Flickr REST endpoint without any extra wrappers or libraries, this post is for you. I will create a simple photo search mobile app in this post but you can easily adapt this to any other methods exposed by the endpoint. Essentially, once you understand [...]]]></description>
			<content:encoded><![CDATA[<p>If you are curious about how to connect directly to the Flickr REST endpoint without any extra wrappers or libraries, this post is for you. I will create a simple photo search mobile app in this post but you can easily adapt this to any other methods exposed by the endpoint. Essentially, once you understand how to connect to this API, you can connect to other REST APIs the same way.<span id="more-195"></span></p>
<p>I&#8217;ve set up the GUI for my app with a search box in the ActionBar and a Search button. The user will enter a keyword in this search box and click search to look for photos on Flickr. The rest of the view has a List component that is constrained on all sides to span the entire area. The search results are displayed in this List. Screenshots of the app are below.</p>
<p><a href="http://www.flexgallery.com/wp-content/uploads/2011/07/FlickrRESTDCD1.png"><img src="http://www.flexgallery.com/wp-content/uploads/2011/07/FlickrRESTDCD1.png" alt="" title="FlickrRESTDCD1" width="800" class="aligncenter" /></a></p>
<p>In this application, the method I want to invoke on the REST endpoint is: </p>
<p><strong><code>http://api.flickr.com/services/rest/?method=flickr.photos.search&#038;api_key={API_KEY}&#038;text={KEYWORD}&#038;per_page=20</code></strong></p>
<p>In your call, you would replace API_KEY with your Flickr API key, and KEYWORD with the keywords from the search input box. You can add additional parameters to this request if you want, but I only need to search by keyword in this sample. I am using the per_page parameter to limit the number of results from the search.</p>
<p>Connecting to a web service using the DCD features of Flash Builder couldn&#8217;t be simpler. In Builder, select Data > Connect to HTTP&#8230; and enter the URL above with a sample keyword and api key in the Operation1 URL field. Click the Add button below the list. The parameters table below should populate with the input parameters. Rename Operation1 to something more readable like searchByKeyword. Enter a Service Name. The dialog should look like this: </p>
<p><a href="http://www.flexgallery.com/wp-content/uploads/2011/07/FlickrRESTDCD2.png"><img src="http://www.flexgallery.com/wp-content/uploads/2011/07/FlickrRESTDCD2.png" alt="" title="FlickrRESTDCD2" width="750" class="aligncenter" /></a></p>
<p>Once your service is set up, you can configure the return type and let Builder generate the data model for you. Right click on the searchByKeyword method in the Data/Services tab and select Configure Return Type. In the dialog, leave the default Auto-detect option selected and click Next. Enter parameters if they are not already populated and click Next. Name the new data type something like SearchResponse and click Finish. If you expand the Data Types branch in the Data/Services tab, you&#8217;ll see the generated data types. To add this new service and the method to your application, right click on the searchByKeyword method and select Generate Service Call.</p>
<p>All that&#8217;s left to do now is to wire up the GUI. The completed source code for this View is below. If it&#8217;s unclear what I am doing in the iconFunction to generate the icons, refer to the Flickr <a href="http://www.flickr.com/services/api/misc.urls.html">reference</a> on it.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;s:View xmlns:fx=&quot;http://ns.adobe.com/mxml/2009&quot;
		xmlns:s=&quot;library://ns.adobe.com/flex/spark&quot;
		xmlns:flickrservice=&quot;services.flickrservice.*&quot;
		viewActivate=&quot;viewActivateHandler(event)&quot;&gt;

	&lt;fx:Script&gt;
		&lt;![CDATA[
			import mx.rpc.events.FaultEvent;
			import mx.rpc.events.ResultEvent;

			import spark.events.ViewNavigatorEvent;

			import valueObjects.SearchResponse;

			private const API_KEY:String = &quot;Enter your API key&quot;;

			protected function viewActivateHandler(event:ViewNavigatorEvent):void
			{
				searchByKeywordResult.addEventListener(ResultEvent.RESULT, searchByKeywordResultHandler);
			}

			private function searchByKeywordResultHandler(event:ResultEvent):void
			{
				var searchResponse:SearchResponse = searchByKeywordResult.lastResult;
				if (searchResponse.stat == &quot;ok&quot;)
				{
					listPhotos.dataProvider = searchResponse.photos.photo;
				}
			}

			protected function btnSearch_clickHandler(event:MouseEvent):void
			{
				searchByKeyword(&quot;flickr.photos.search&quot;, API_KEY, txtInput.text);
			}

			protected function searchByKeyword(method:String, api_key:String, text:String, per_page:String='20'):void
			{
				searchByKeywordResult.token = flickrService.searchByKeyword(method, api_key, text, per_page);
			}

		]]&gt;
	&lt;/fx:Script&gt;
	&lt;fx:Declarations&gt;
		&lt;s:CallResponder id=&quot;searchByKeywordResult&quot;/&gt;
		&lt;flickrservice:FlickrService id=&quot;flickrService&quot;/&gt;
	&lt;/fx:Declarations&gt;

	&lt;s:titleContent&gt;
		&lt;s:TextInput id=&quot;txtInput&quot; prompt=&quot;Keyword(s)&quot; width=&quot;100%&quot;/&gt;
	&lt;/s:titleContent&gt;
	&lt;s:actionContent&gt;
		&lt;s:Button id=&quot;btnSearch&quot; label=&quot;Search&quot; click=&quot;btnSearch_clickHandler(event)&quot;/&gt;
	&lt;/s:actionContent&gt;
	&lt;s:List id=&quot;listPhotos&quot; left=&quot;0&quot; right=&quot;0&quot; top=&quot;0&quot; bottom=&quot;0&quot;&gt;
		&lt;s:itemRenderer&gt;
			&lt;fx:Component&gt;
				&lt;s:IconItemRenderer labelField=&quot;&quot; messageField=&quot;title&quot; iconFunction=&quot;getImageThumbnailURL&quot;&gt;
					&lt;fx:Script&gt;
						&lt;![CDATA[
							import valueObjects.Photo;
							private function getImageThumbnailURL(item:Photo):Object
							{
								return &quot;http://farm&quot; + item.farm + &quot;.static.flickr.com/&quot; + item.server + &quot;/&quot; + item.id + &quot;_&quot; + item.secret + &quot;_s.jpg&quot;;
							}
						]]&gt;
					&lt;/fx:Script&gt;
				&lt;/s:IconItemRenderer&gt;
			&lt;/fx:Component&gt;
		&lt;/s:itemRenderer&gt;
	&lt;/s:List&gt;
&lt;/s:View&gt;
</pre>
<img src="http://feeds.feedburner.com/~r/FlexGallery/~4/2poVqAx2-qc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.flexgallery.com/2011/07/connecting-to-the-flickr-rest-endpoin-with-dcd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.flexgallery.com/2011/07/connecting-to-the-flickr-rest-endpoin-with-dcd/</feedburner:origLink></item>
		<item>
		<title>Setting ActionBar Button style based on platform</title>
		<link>http://feedproxy.google.com/~r/FlexGallery/~3/wviZr4MQ7gA/</link>
		<comments>http://www.flexgallery.com/2011/07/setting-actionbar-button-style-based-on-platform/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 18:14:36 +0000</pubDate>
		<dc:creator>Shashwati Keith</dc:creator>
				<category><![CDATA[CSS Media Query]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Mobile ActionBar]]></category>

		<guid isPermaLink="false">http://www.flexgallery.com/?p=123</guid>
		<description><![CDATA[The typical iOS application has beveled buttons in the ActionBar. On Android, the buttons are flat. There is a property on ActionBar called defaultButtonAppearance which can be set to beveled or normal. By default it is set to normal. You can use CSS Media Queries to set the button style based on platform. This feature [...]]]></description>
			<content:encoded><![CDATA[<p>The typical iOS application has beveled buttons in the ActionBar. On Android, the buttons are flat. There is a property on ActionBar called <code>defaultButtonAppearance</code> which can be set to beveled or normal. By default it is set to normal. You can use CSS Media Queries to set the button style based on platform. <span id="more-123"></span> This feature was introduced in Flex 4.5 and it works on desktop and mobile applications. The supported media features are application DPI (160, 240, 320) and platform (IOS, Android, QNX, Windows, Macintosh). </p>
<p>Here&#8217;s how you can switch between beveled and non-beveled buttons between Android and IOS:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;fx:Style&gt;
	@namespace s &quot;library://ns.adobe.com/flex/spark&quot;;
	@media (os-platform: &quot;Android&quot;)
	{
		s|ActionBar
		{
			defaultButtonAppearance: normal;
		}
	}
	@media (os-platform: &quot;IOS&quot;)
	{
		s|ActionBar
		{
			defaultButtonAppearance: beveled;
		}
	}
&lt;/fx:Style&gt;
</pre>
<p>You would declare your media queries in the Style block of your main application mxml file. You can also declare them in any custom MXML components but the usual rules of CSS declarations apply. You can set type or class selectors in the main application file but only class selectors in custom components.</p>
<p>If you haven&#8217;t tried media queries yet, check it out. It&#8217;s an easy way to set styles for different devices without having to create a new theme or SWF for each.</p>
<img src="http://feeds.feedburner.com/~r/FlexGallery/~4/wviZr4MQ7gA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.flexgallery.com/2011/07/setting-actionbar-button-style-based-on-platform/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.flexgallery.com/2011/07/setting-actionbar-button-style-based-on-platform/</feedburner:origLink></item>
		<item>
		<title>ItemRenderer: Changing font on hover/selection</title>
		<link>http://feedproxy.google.com/~r/FlexGallery/~3/71OdkRIpXkk/</link>
		<comments>http://www.flexgallery.com/2011/07/changing-itemrenderer-font-on-rollover/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 21:32:45 +0000</pubDate>
		<dc:creator>Shashwati Keith</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[Spark ItemRenderer]]></category>

		<guid isPermaLink="false">http://www.flexgallery.com/?p=82</guid>
		<description><![CDATA[The other day I was working on a web app that has a Spark List, and I wanted to customize how a selected or hovered item looked. By default, when you hover over or select a list item, the background color of the renderer changes. I wanted to change the font style instead. This is [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I was working on a web app that has a Spark List, and I wanted to customize how a selected or hovered item looked. By default, when you hover over or select a list item, the background color of the renderer changes. I wanted to change the font style instead. This is easy to do with ItemRenderer states.<span id="more-82"></span></p>
<p>Let&#8217;s say you have a basic Spark List in your application.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;s:Application xmlns:fx=&quot;http://ns.adobe.com/mxml/2009&quot;
			   xmlns:s=&quot;library://ns.adobe.com/flex/spark&quot;
			   xmlns:mx=&quot;library://ns.adobe.com/flex/mx&quot;&gt;
	&lt;s:List width=&quot;200&quot; height=&quot;200&quot; itemRenderer=&quot;FontChangeRenderer&quot;&gt;
		&lt;s:dataProvider&gt;
			&lt;s:ArrayList&gt;
				&lt;fx:String&gt;Item 1&lt;/fx:String&gt;
				&lt;fx:String&gt;Item 2&lt;/fx:String&gt;
				&lt;fx:String&gt;Item 3&lt;/fx:String&gt;
			&lt;/s:ArrayList&gt;
		&lt;/s:dataProvider&gt;
	&lt;/s:List&gt;
&lt;/s:Application&gt;
</pre>
<p>Below is the code for FontChangeRenderer which is a custom ItemRenderer. Notice that I set autoDrawBackground to false. This prevents the background from changing color on hover and selection.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;s:ItemRenderer xmlns:fx=&quot;http://ns.adobe.com/mxml/2009&quot;
				xmlns:s=&quot;library://ns.adobe.com/flex/spark&quot;
				xmlns:mx=&quot;library://ns.adobe.com/flex/mx&quot;
				autoDrawBackground=&quot;false&quot;&gt;
	&lt;s:states&gt;
		&lt;s:State name=&quot;normal&quot;/&gt;
		&lt;s:State name=&quot;selected&quot;/&gt;
		&lt;s:State name=&quot;hovered&quot;/&gt;
	&lt;/s:states&gt;
	&lt;s:Label text=&quot;{data}&quot;
			 fontWeight.hovered=&quot;bold&quot; fontStyle.selected=&quot;italic&quot;/&gt;
&lt;/s:ItemRenderer&gt;
</pre>
<p>I used ItemRenderer states to change the fontStyle and fontWeight styles. On hover, the Label will be bold, and on selection it will be italicized. The output is below (you can rollover and select items):</p>
<p>

<object width="200" height="200">
<param name="movie" value="http://www.flexgallery.com/wp-content/uploads/2011/07/ItemRendererStatesFontChange.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="200" height="200" src="http://www.flexgallery.com/wp-content/uploads/2011/07/ItemRendererStatesFontChange.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<img src="http://feeds.feedburner.com/~r/FlexGallery/~4/71OdkRIpXkk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.flexgallery.com/2011/07/changing-itemrenderer-font-on-rollover/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.flexgallery.com/2011/07/changing-itemrenderer-font-on-rollover/</feedburner:origLink></item>
		<item>
		<title>MuniTracker for Android and IOS</title>
		<link>http://feedproxy.google.com/~r/FlexGallery/~3/migvM9a3-ag/</link>
		<comments>http://www.flexgallery.com/2011/07/munitracker-for-android-and-ios/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 07:00:19 +0000</pubDate>
		<dc:creator>Shashwati Keith</dc:creator>
				<category><![CDATA[Applications]]></category>

		<guid isPermaLink="false">http://www.flexgallery.com/?p=30</guid>
		<description><![CDATA[I developed MuniTracker for Android and IOS using Flash Builder and Flex SDK 4.5 and 4.5.1. It has been on the respective app stores for a few months with thousands of downloads. The application took me about 3-4 days to create, and 2-3 more days to make it work across the two platforms and to [...]]]></description>
			<content:encoded><![CDATA[<p>I developed MuniTracker for Android and IOS using Flash Builder and Flex SDK 4.5 and 4.5.1. It has been on the respective app stores for a few months with thousands of downloads. The application took me about 3-4 days to create, and 2-3 more days to make it work across the two platforms and to prepare it for app store upload. This is an amazingly short time to create any mobile application but such is the beauty of Flex. <span id="more-30"></span></p>
<p>MuniTracker lets you track San Francisco Muni locations and arrival times with a live map. For those of you unfamiliar with the San Francisco transit system, the Muni is the bus, trolley and cable car system. SFMTA publishes an XML feed with live bus locations and arrival times that update frequently. MuniTracker polls this feed every 10 seconds.</p>
<p>One of the most useful features of MuniTracker is the ability to view routes and current bus locations on a map. I use ESRI&#8217;s street maps in this application. When you are in the map view, you can see the locations of the buses update every 10 seconds along with their arrival times. Another useful feature is the ability to bookmark your favorite stops and lines for easy access later. There is a mini browser embedded in the application that displays the SFMTA website where the agency frequently posts delay information and other news.</p>
<p>You can download MuniTracker today from the two app stores:</p>
<p><a href="http://itunes.apple.com/us/app/munitracker/id436932756">MuniTracker for IOS</a></p>
<p><a href="https://market.android.com/details?id=air.MuniTracker">MuniTracker for Android</a></p>
<p style="text-align: center;"><a href="http://www.flexgallery.com/wp-content/uploads/2011/07/MuniTrackerScreenshots.png"><img class="aligncenter size-full wp-image-68" title="MuniTrackerScreenshots" src="http://www.flexgallery.com/wp-content/uploads/2011/07/MuniTrackerScreenshots.png" alt="" width="540" height="270" /></a></p>
<img src="http://feeds.feedburner.com/~r/FlexGallery/~4/migvM9a3-ag" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.flexgallery.com/2011/07/munitracker-for-android-and-ios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.flexgallery.com/2011/07/munitracker-for-android-and-ios/</feedburner:origLink></item>
	</channel>
</rss>

