MACROMEDIA FLEX-GETTING STARTED WITH FLEX Uživatelský manuál Strana 101

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 148
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 100
images don’t have to be local; they can be any URL, pointing
to any server. So, the list could be a set of URLs to various
images. And that list could easily be loaded from an external
XML file using the HTTP support in Flex.
Back to the example at hand: I like the functionality, but the
presentation is a little bland. So, let’s make it more interesting
by showing thumbnails of the images in the list. I do that in
Example 6-4.
Example 6-4. Pictures2.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="horizontal"
horizontalAlign="left">
<mx:Array id="images">
<mx:String>megan1.jpg</mx:String>
<mx:String>megan2.jpg</mx:String>
<mx:String>megan3.jpg</mx:String>
<mx:String>megan4.jpg</mx:String>
<mx:String>megan5.jpg</mx:String>
</mx:Array>
<mx:List id="ctlImage" dataProvider="{images}"
selectedIndex="0" width="50">
<mx:itemRenderer>
<mx:Component>
<mx:Image source="{data}” width="50” height="50” />
</mx:Component>
</mx:itemRenderer>
</mx:List>
<mx:Image source="{ctlImage.selectedItem.valueOf()}"
height="400" />
</mx:Application>
The only thing that has changed in this code is that I have added
an itemRenderer to the list. That is an optional attribute that
you can add to Flex controls so that you can render each cell
in a table or list yourself. In this case, I provide an inline com-
ponent that creates an mx:Image for each cell in the list.
I then run this in Flex Builder; the result appears in Figure 6-5.
Now I have thumbnails instead of images. Yes, it’s really that
easy. The item rendering and component support in Flex is
A Simple Image Viewer | 85
Zobrazit stránku 100
1 2 ... 96 97 98 99 100 101 102 103 104 105 106 ... 147 148

Komentáře k této Příručce

Žádné komentáře