Actionscript 3 Flex 3 XML提要TileList将所选项传递给另一个组件

Actionscript 3 Flex 3 XML提要TileList将所选项传递给另一个组件,actionscript-3,flex3,Actionscript 3,Flex3,在创建完成时,我有一个由xml填充的TileList,我希望将所选项目中的图像传递到图像组件的源 这是主要应用程序: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" backgroundColor="#FFFFFF"> <mx:ArrayCollection id="theImage

在创建完成时,我有一个由xml填充的TileList,我希望将所选项目中的图像传递到图像组件的源

这是主要应用程序:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" backgroundColor="#FFFFFF">
<mx:ArrayCollection id="theImages"></mx:ArrayCollection>
<mx:Model id="items" source="items.xml" />
<mx:Script>
    <![CDATA[
        import ItemListObject;
        public function initList():void
         {
          for each ( var node:Object in items.image ) {
           var temp:ItemListObject = new ItemListObject();
           temp.strThumbnail = node.strThumbnail;
           temp.title = node.title;
           theImages.addItem(temp);
          }
 }
    ]]>
</mx:Script>
<mx:XML source="adjectives.xml" id="adjectivesXML"/>
    <mx:Canvas x="20" y="20">
        <mx:Image 
            id="item"
            source="????" 
            autoLoad="true" 
            width="500" 
            height="500" 
            scaleContent="true"/>
    </mx:Canvas>
    <mx:TileList id="imageTileList"
        itemRenderer="CustomItemRenderer"
        dataProvider="{theImages}"
        width="400"
        height="400"
        columnCount="2"
        creationComplete="initList();"/>
    </mx:Application>
这是一个非常粗糙的例子,但一旦我克服了这个困难,我就能做更多我想做的事情。感谢阅读。

最快的方法是:

<mx:Image id="img" source="{imageTileList.selectedItem.strThumbnail}" />
数据对象用于项目渲染器内部而不是外部。一个数据对象表示传递到渲染器的xml中的一个图像

确保检查项目呈现器的文档

<?xml version="1.0" encoding="utf-8"?>
<items>
 <image id="1">
    <title>Image 1</title>
    <strThumbnail>1.jpg</strThumbnail>
 </image>
 <image id="2">
    <title>Image 2</title>
    <strThumbnail>2.jpg</strThumbnail>
 </image>
 <image id="3">
    <title>Image 3</title>
    <strThumbnail>3.jpg</strThumbnail>
 </image>
 <image id="4">
    <title>Image 4</title>
    <strThumbnail>4.jpg</strThumbnail>
 </image>    
</items>
package
{
 [Bindable]
 public class ItemListObject extends Object
 {
  public function ItemListObject() {
   super();
  }

  public var title:String = new String();
  public var strThumbnail:String = new String();
 }
}
<mx:Image id="img" source="{imageTileList.selectedItem.strThumbnail}" />