MACROMEDIA FLEX-GETTING STARTED WITH FLEX Bedienungsanleitung Seite 126

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 148
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 125
paddingTop="0"
creationComplete="flickReq.send();" backgroundAlpha="0"
backgroundColor="white"
backgroundGradientColors="[0xFFFFFF,0xFFFFFF]">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
private var images:Array = [];
private var currentImage:int = 0;
private function onFetchResult( event:ResultEvent ) : void {
var items:ArrayCollection = event.result.rss.channel.item as
ArrayCollection;
for each ( var item:Object in items )
images.push( item.thumbnail.url.toString() );
flickImg.source = images[currentImage];
var t:Timer = new Timer( 2000 );
t.addEventListener( TimerEvent.TIMER, onTimer );
t.start();
}
private function onTimer( event:Event ) : void {
currentImage += 1;
if ( currentImage >= images.length )
currentImage = 0;
flickImg.source = images[currentImage];
}
]]>
</mx:Script>
<mx:HTTPService id="flickReq"
url="http://api.flickr.com/services/feeds
/photos_public.gne?format=rss_200_enc"
result="onFetchResult(event)" />
<mx:Image width="100" height="100" id="flickImg">
<mx:filters><mx:DropShadowFilter /></mx:filters>
</mx:Image>
</mx:Application>
At the top of the application I define two methods. The first is
onFetchResult, which handles the response from Flickr and
sets up the list of images. The onFetchResult method also sets
up a timer that calls back to the onTimer method every 2,000
milliseconds (every two seconds) to change the source of the
image. The bottom portion of the example defines the HTTPSer
vice to connect to, and the image object to use to display the
Flickr image.
110 | Chapter 8:Flex for Widgets
Seitenansicht 125
1 2 ... 121 122 123 124 125 126 127 128 129 130 131 ... 147 148

Kommentare zu diesen Handbüchern

Keine Kommentare