62 lines
1.8 KiB
ActionScript
62 lines
1.8 KiB
ActionScript
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 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;
|
|
}
|
|
}
|
|
}
|