beginning custom version of 03d4

cat-town
Dan Buch 15 years ago
parent 4ebee454f9
commit 111bf2c489

@ -0,0 +1,37 @@
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;
}
}
}

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<loc:TileListApp xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:loc="*"
backgroundColor="#FFFFFF"
backgroundAlpha="0"
horizontalAlign="left"
verticalGap="15" horizontalGap="15">
<!-- photo service -->
<mx:HTTPService id="photoService"
url="http://api.flickr.com/services/feeds/photos_public.gne"
result="photoHandler(event)" />
<!-- search -->
<mx:Form>
<mx:FormItem label="Search Term"
direction="horizontal">
<mx:TextInput id="searchTerms" />
<mx:Button label="Search"
click="requestPhotos()" />
</mx:FormItem>
</mx:Form>
<!-- result, data is passed to the itemRenderer by Flex
through the data property -->
<mx:TileList id="mylist"
labelField="thumbnail"
dataProvider="{photoFeed}"
width="600" height="200"
paddingTop="25" left="5"
itemClick="showMessage(event)">
<mx:itemRenderer>
<mx:Component>
<mx:VBox width="125" height="125"
paddingRight="5" paddingLeft="5"
horizontalAlign="center">
<mx:Image
height="75" width="75"
source="{data.thumbnail.url}"/>
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:TileList>
<mx:Text id="textMessage" paddingTop="20" />
</loc:TileListApp>
Loading…
Cancel
Save