Sponsored Link •
|
Summary
Christophe has provided sample Flex and MXML source worth a peek. While crafting a browser-based RSS reader is not exactly a likely use case, it is more interesting than yet another Hello World intro, and it illustrates just how much can be accomplished in Flash with a few lines of MXML.
Advertisement
|
I wouldn't look to replace NetNewsWire or FeedDemon (I'm one of those guys who wears out carpet and the swivel feature of his chair by working simultaneously on a Mac and a PC all day long) but what's encouraging to me about this example is just how much can be accomplished with a few declarations using MXML and the Flash components bundled in Flex. It reminds me a bit of how I sometimes feel using Ruby or Python for certain tasks in a Java-dominated server world, in that while not appropriate in every tier -- it seems to excel in the web presentation tier -- it's refreshingly simple without sacrificing power.
Link: http://www.markme.com/cc/archives/003901.cfm
Screenshot:
Source:
<?xml version="1.0" encoding="iso-8859-1"?>
<mx:Application width="900" height="600" xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Style src="main.css"/>
<mx:Script>
var selectedBlog;
var selectedEntry;
function treeItemSelected(evt) {
// When a new blog is selected in the tree, use the HTTPService to get the feed
var url=evt.target.selectedItem.attributes.url;
if (url!=null) {
selectedBlog=url;
feed.send();
}
}
</mx:Script>
<!-- an XML document containing the list of blogs I read -->
<mx:XML id="treeModel" src="tree.xml"/>
<!-- The HTTP Service used to get the feeds -->
<mx:HTTPService id="feed" url="{selectedBlog}"/>
<mx:HBox>
<!-- The tree displaying blogs organized by categories -->
<mx:Tree width="250" heightFlex="1" change="treeItemSelected(event);">
{treeModel}
</mx:Tree>
<mx:VBox>
<!-- The blog header -->
<mx:VBox verticalGap="0" backgroundColor="#EEF5EE" borderStyle="outset" widthFlex="1">
<mx:Label styleName="title">
{feed.result.rss==null?feed.result.RDF.channel.title:feed.result.rss.channel.title}
</mx:Label>
<mx:Label>
{feed.result.rss==null?feed.result.RDF.channel.date:feed.result.rss.channel.lastBuildDate}
</mx:Label>
<mx:Link click="getUrl('mailto:'+event.target.label)">
{feed.result.rss==null?feed.result.RDF.channel.link:feed.result.rss.channel.link}
</mx:Link>
</mx:VBox>
<!-- A datagrid displaying the post titles for the selected blog -->
<mx:DataGrid widthFlex="1" height="220" change="selectedEntry=event.target.selectedItem"
dataProvider="{feed.result.rss==null?feed.result.RDF.item:feed.result.rss.channel.item}"
columnNames="{feed.result.rss==null?['title','date']:['title','pubDate']}"/>
<!-- The post excerpt -->
<mx:TextArea id="description" widthFlex="1" heightFlex="1" html="true" wordWrap="true" editable="false">
{selectedEntry.description}
</mx:TextArea>
<!-- A link to the article in the original blog -->
<mx:Link id="itemLink" click="getUrl(event.target.label, '_blank')">
{selectedEntry.link}
</mx:Link>
</mx:VBox>
</mx:HBox>
</mx:Application>
Have an opinion? Readers have already posted 1 comment about this weblog entry. Why not add yours?
If you'd like to be notified whenever Sean Neville adds a new entry to his weblog, subscribe to his RSS feed.
Sean Neville is a software architect at Macromedia where he is focused on creating the Flex platform. His previous projects include the JRun application server and Flash-related products for J2EE and .NET. His experiences include membership in the JCP Executive Committee and numerous JSR expert groups; authoring articles, contributing to books, and speaking on enterprise topics; financial services app consulting; building doomed yet fun web startups; maintaining open source projects; and half-decent fiddling of Irish jigs and reels. |
Sponsored Links
|