package
{
    import mx.core.Application;
    import mx.controls.TextInput;
    import mx.controls.Text;
    import mx.collections.ArrayCollection;
    import mx.events.ListEvent;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.http.HTTPService;

    public class TileListApp extends Application
    {
        [Bindable]
        public var photoFeed:ArrayCollection = new ArrayCollection();
        public var searchTerms:TextInput;
        public var photoService:HTTPService;
        public var textMessage:Text;

        public function requestPhotos():void {
            var params:Object = new Object();
            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;
        }

        //show text message when user selects image
        public function showMessage(event:Event):void {
            textMessage.text = "You selected: " +
                event.currentTarget.selectedItem.title + "\nUploaded by: " +
                event.currentTarget.selectedItem.credit;
        }
    }
}
