Recently in tutorials Category
Yahoo Pipes is a pretty nifty utility for quickly bundling data sources from the web into one neat feed. While you can do nearly everything Pipes does with ActionScript, the feeds must be cached locally for flash player to access them because of crossdomain policies. For this reason, it is nice to only have to cache one feed, instead of caching several and then piecing them all together. This also makes it easy to modify the data feed later on through the Pipes interface without having to touch ActionScript. Building a Yahoo Pipes app
First, sign up for a Yahoo Pipes account if you haven't already: http://pipes.yahoo.com/pipes/Next, create a simple Application. There are plenty of examples out there. You can always clone someone else's pipe, and modify it with your own favorite data sources.
For this tutorial, I have created an app that pulls feeds from Digg.com, and combines snapshots of the articles from Snap.com
The sample app can be viewed here:http://pipes.yahoo.com/pipes/pipe.info?_id=xv9z9HSr3BG_6gN48jxBKg
Setting up PHP caching
I am using a PHP RSS caching script called RSS Fetch. It can be easily customized to cache at specified intervals, or constantly pull the newest data. I have added a line to the rsslist array for the yahoo pipes RSS source:
"Pipes" => "http://pipes.yahoo.com/pipes/pipe.run?_id=xv9z9HSr3BG_6gN48jxBKg&_render=rss"
You'll also need to create a "cache" directory for the script to write to. My example can be seen here:
http://infinitearray.com/experiments/feeder/rssfetch.php?id=Pipes&cachetime=5
Creating a Flex App
Luckily, Adobe has done most of the work here. They've open sourced a few libraries that take care of parsing RSS feeds. You'll need both the as3corelib and the as3syndicationlib. Mike Chambers has built a great demo App for working with these libraries.
I've built a simple demo application in Flex that pushes the Yahoo Pipes RSS feed into a TileList component.
I've packaged the entire source for this application, including the external libraries.
View Source
This is quite a simple tutorial. It is more about design than programming. It will cover adding an application gradient background, and then overlaying a tiled PNG pattern on top. With a little creativity, this effect can make a nice application or website background that is not easily reproducible with html / css.
First, begin by setting up your application. First we’ll add a background gradient, and set up a few other parameters:
| <?xml version=”1.0” encoding=”utf-8”?> <mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” width=”100%” height=”100%” fontAntiAliasType=”advanced” layout=”absolute” backgroundGradientColors=”[#535353, #2f2f2f]” horizontalScrollPolicy=”off”> |
Next, we add a VBox that will take up the whole application background. The CSS class dottedBG will contain the location for the tile image:
| <mx:VBox width=”100%” height=”100%” verticalAlign=”top” horizontalAlign=”center” verticalGap=”0” paddingLeft=”0” paddingRight=”0” paddingTop=”30” paddingBottom=”20” styleName=”dottedBG” horizontalCenter=”0”> |
Finally, add the CSS class:
| .dottedBG{ background-image: Embed(“dottedtile.png”); } |
I will post the source for this example soon. Feel free to post links to your own examples.
| drawHeaderBackground(headerBG:UIComponent):void drawRowBackgrounds():void drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void |
Next, comes the actual override code. I have created an AS file named DrawListingsGrid.as in the pkg/controls/ directory of the project. I have added comments as place holders in the areas where adjustments are made.
package pkg.controls import flash.display.DisplayObject; use namespace mx_internal; public class DrawListingsGrid extends DataGrid // embedding an image for the row background // embedding an image for the header background // filling in header with embedded background image
//fill the row background with the embedded image |
In order to use this class, you will need to embed it as a custom component in the MXML file.
| <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:con="pkg.controls.*"> |
Next, you can actually add the component to the stage, by referencing the link from the header:
<con:DrawListingsGrid width="100%" height="100%"> |

