Created
December 11, 2009 11:43
-
-
Save aerith/254154 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="600" height="400" paddingLeft="0" paddingTop="0" paddingBottom="0" paddingRight="0" creationComplete="creationCompleteHandler()"> | |
<mx:Script> | |
<![CDATA[ | |
import mx.binding.utils.BindingUtils; | |
import flash.net.URLLoader; | |
import flash.net.URLRequest; | |
import flash.net.URLVariables; | |
import mx.collections.XMLListCollection; | |
public var request:URLRequest = new URLRequest(); | |
public var loader:URLLoader = new URLLoader(); | |
public var variables:URLVariables = new URLVariables(); | |
[Bindable] | |
private var feed_data:XMLListCollection; | |
private function creationCompleteHandler ():void { | |
variables.url = Application.application.parameters.url; | |
request.url = './feed.php'; | |
request.data = variables; | |
loader.addEventListener(Event.COMPLETE, feedLoadCompleteHandler); | |
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); | |
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); | |
loader.load(request); | |
} | |
private function feedLoadCompleteHandler (event:Event):void { | |
var feed:XML = new XML(loader.data); | |
var namespace:Namespace = feed.namespace(''); | |
var items:XMLList = feed.namespace::item; | |
feed_data = new XMLListCollection(items); | |
} | |
private function ioErrorHandler (event:Event):void { | |
} | |
private function securityErrorHandler (event:Event):void { | |
} | |
private function itemNamespaceHandler (item:Object, column:DataGridColumn):Object { | |
var namespace:Namespace = item.namespace(''); | |
switch (column.dataField) { | |
case "date": | |
var sub_namespace:Namespace = item.namespace('dc'); | |
return item.sub_namespace::[column.dataField].text(); | |
} | |
return item.namespace::[column.dataField].text(); | |
} | |
]]> | |
</mx:Script> | |
<mx:DataGrid id="feed_grid" width="100%" height="100%" dataProvider="{feed_data}"> | |
<mx:columns> | |
<mx:DataGridColumn dataField="title" labelFunction="{itemNamespaceHandler}" /> | |
<mx:DataGridColumn dataField="date" labelFunction="{itemNamespaceHandler}" /> | |
<mx:DataGridColumn dataField="link" labelFunction="{itemNamespaceHandler}" /> | |
</mx:columns> | |
</mx:DataGrid> | |
</mx:Application> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment