Yup, this my second Adobe AIR application and YES it is another RSS Reader
but this time I was studying how to manipulate XML data in ActionScript 3.0 using E4X syntax “really cool BTW”. Of course the source code is huge if you compared it to the Flex version of the same application I have posted earlier, cause at the moment I want (and hope) to master ActionScript 3.0, its the neatest OOP language I have developed with, so I am trying to write ActionScript code as much as I can.. I want to reach the level where I can write a complete Flex /AIR application purely in ActionScript “of course I mean a complex one” wish me LUCK
..
Screenshot:
Source code:
//RSSGrabber.as
package org.amrkamel.rss {
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class RSSGrabber extends EventDispatcher {
//class properties
private var _urlRequest:URLRequest;
private var _urlLoader:URLLoader;
private var _feed:XML;
private var _items:XMLList;
private var _feedTitle:String;
private var _feedDescription:String;
//constructor
public function RSSGrabber(){
_urlLoader = new URLLoader();
}
//event handler when URLLoader loads teh external XML
private function onComplete(event:Event):void {
initFeed();
/*
* dispatch event
* TODO: try to declare a new type of event
* specific to GRSSReader
*/
dispatchEvent(new Event(Event.COMPLETE));
}
private function initFeed():void {
_feed = XML(_urlLoader.data);
_items = _feed..item;
_feedTitle = _feed.channel.title;
_feedDescription = _feed.channel.description;
}
//implicit setters
public function set urlRequest(urlRequest:URLRequest):void {
this._urlRequest = urlRequest;
}
public function set urlLoader(urlLoader:URLLoader):void {
this._urlLoader = urlLoader;
}
public function set feed(feed:XML):void {
this._feed = feed;
}
public function set items(items:XMLList):void {
this._items = items;
}
public function set feedTitle(feedTitle:String):void {
this._feedTitle = feedTitle;
}
public function set feedDescription(feedDescription:String):void {
this._feedDescription = feedDescription;
}
//implicit getters
public function get urlRequest():URLRequest {
return this._urlRequest;
}
public function get urlLoader():URLLoader {
return this._urlLoader;
}
public function get feed():XML {
return this._feed;
}
public function get items():XMLList {
return this._items;
}
public function load():void {
_urlLoader.load(_urlRequest);
_urlLoader.addEventListener(Event.COMPLETE, onComplete);
}
public function get feedTitle():String {
return this._feedTitle;
}
public function get feedDescription():String {
return this._feedDescription;
}
}
}
<!-- RSSReader.mxml -->
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" paddingTop="0">
<mx:Script>
<![CDATA[
import org.amrkamel.rss.RSSGrabber;
import flash.net.URLLoader;
[Bindable]
public var rssGrabber:RSSGrabber = new RSSGrabber();
public function startRSS():void {
itemsDataGrid.dataProvider = null;
rssGrabber.urlRequest = new URLRequest(urlTxtInpt.text);
rssGrabber.load();
rssGrabber.addEventListener(Event.COMPLETE, rssReady);
}
private function rssReady(event:Event):void {
titleLbl.text = rssGrabber.feedTitle;
itemsDataGrid.dataProvider = rssGrabber.items;
}
private function onItemClick():void {
itemTxtArea.htmlText =
rssGrabber.items[itemsDataGrid.selectedIndex].description;
}
]]>
</mx:Script>
<mx:ApplicationControlBar width="100%">
<mx:Label text="URL: " fontWeight="bold" width="6%" />
<mx:TextInput id="urlTxtInpt" width="64%"/>
<mx:Button width="10%" enabled="true"
icon="@Embed(source='../assets/images/play_button.png')"
click="startRSS()"/>
</mx:ApplicationControlBar>
<mx:Label id="titleLbl" />
<mx:DataGrid id="itemsDataGrid" width="100%"
click="onItemClick()">
<mx:columns>
<mx:DataGridColumn headerText="Title" dataField="title"/>
<mx:DataGridColumn headerText="Date" dataField="pubDate"/>
</mx:columns>
</mx:DataGrid>
<mx:TextArea id="itemTxtArea" width="100%" height="100%"/>
</mx:WindowedApplication>

November 9, 2008 at 8:02 am
so you dont have a compiled version of this application so i could try it?