From cffa4944258f666a5d2c047384db122cbdfeec53 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Fri, 19 Feb 2010 22:02:07 -0500 Subject: [PATCH] making DataGridExample more sane wrt separation of mxml & as --- 03d1-datagrid/DataGridApp.as | 61 +++++++++++++++++++++++++++ 03d1-datagrid/DataGridExample.mxml | 66 +++++++----------------------- 2 files changed, 75 insertions(+), 52 deletions(-) create mode 100644 03d1-datagrid/DataGridApp.as diff --git a/03d1-datagrid/DataGridApp.as b/03d1-datagrid/DataGridApp.as new file mode 100644 index 0000000..240e11e --- /dev/null +++ b/03d1-datagrid/DataGridApp.as @@ -0,0 +1,61 @@ +package +{ + import mx.core.Application; + + import mx.collections.ArrayCollection; + import mx.containers.Panel; + import mx.controls.Alert; + import mx.controls.DataGrid; + import mx.controls.Image; + import mx.controls.Label; + import mx.controls.TextInput; + import mx.rpc.events.FaultEvent; + import mx.rpc.events.ResultEvent; + import mx.rpc.http.HTTPService; + + import com.ag.RequestParams; + + public class DataGridApp extends Application + { + [Bindable] + public var dataGrid:DataGrid; + public var photoFeed:ArrayCollection; + public var photoService:HTTPService; + public var searchTerms:TextInput; + public var vboxImage:Image; + public var vboxDesc:Label; + public var popup:Panel; + + function DataGridApp() + { + } + + public function requestPhotos():void { + var params:RequestParams = new RequestParams(); + params.format = 'rss_200_enc'; + params.tags = searchTerms.text; + photoService.send(params); + } + + public function photoHandler(event:ResultEvent):void { + photoFeed= event.result.rss.channel.item as ArrayCollection; + dataGrid.dataProvider = photoFeed; + dataGrid.visible = true; + } + + public function faultHandler(event:FaultEvent):void{ + Alert.show(event.fault.faultCode + " , " + event.fault.faultString); + } + + public function showPopup(event:Event):void{ + vboxImage.source = photoFeed.getItemAt(event.currentTarget.selectedIndex).content.url + vboxDesc.text = photoFeed.getItemAt(event.currentTarget.selectedIndex).title.getItemAt(0) + popup.visible = true; + } + + public function hidePopup():void{ + popup.visible = false; + popup.includeInLayout = false; + } + } +} diff --git a/03d1-datagrid/DataGridExample.mxml b/03d1-datagrid/DataGridExample.mxml index a2edcdf..bcd7494 100644 --- a/03d1-datagrid/DataGridExample.mxml +++ b/03d1-datagrid/DataGridExample.mxml @@ -1,54 +1,12 @@ - - - - - - - - + - + - - + + - - + + - +