Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 在AS3数据网格中显示多个图像_Actionscript 3_Datagrid - Fatal编程技术网

Actionscript 3 在AS3数据网格中显示多个图像

Actionscript 3 在AS3数据网格中显示多个图像,actionscript-3,datagrid,Actionscript 3,Datagrid,我需要在datagrid中显示多个图像,但不知道如何显示。我能够显示一个实现ICellRenderer的图像。 由于ICellRenderer在DataProvider中查找数据键并显示该键,因此我无法多次理解如何显示该键 是否可以使用不同类型的数据提供程序或实现不同的接口 这是我用于图像加载的代码: package { // Import the required component classes. import fl.containers.UILoader; import fl.contr

我需要在datagrid中显示多个图像,但不知道如何显示。我能够显示一个实现ICellRenderer的图像。 由于ICellRenderer在DataProvider中查找数据键并显示该键,因此我无法多次理解如何显示该键

是否可以使用不同类型的数据提供程序或实现不同的接口

这是我用于图像加载的代码:

package {
// Import the required component classes.
import fl.containers.UILoader;
import fl.controls.listClasses.ICellRenderer;
import fl.controls.listClasses.ListData;
import fl.core.InvalidationType;
import fl.data.DataProvider;
import flash.events.Event;

/**
 * This class creates a custom cell renderer which displays an image in a cell.
 * Make sure the class is marked "public" and in the case of our custom cell renderer, 
 * extends the UILoader class and implements the ICellRenderer interface.
 */
public class LoaderCellRenderer extends UILoader implements ICellRenderer {
    protected var _data:Object;
    protected var _listData:ListData;
    protected var _selected:Boolean;

    /**
     * Constructor.
     */
    public function LoaderCellRenderer():void {
        super();
    }

    /**
     * Gets or sets the cell's internal _data property.
     */
    public function get data():Object {
        return _data;
    }
    /** 
     * @private (setter)
     */
    public function set data(value:Object):void {
        _data = value;
        source = value.data;
    }

    /**
     * Gets or sets the cell's internal _listData property.
     */
    public function get listData():ListData {
        return _listData;
    }
    /**
     * @private (setter)
     */
    public function set listData(value:ListData):void {
        _listData = value;
        invalidate(InvalidationType.DATA);
        invalidate(InvalidationType.STATE);
    }

    /**
     * Gets or sets the cell's internal _selected property.
     */
    public function get selected():Boolean {
        return _selected;
    }
    /**
     * @private (setter)
     */
    public function set selected(value:Boolean):void {
        _selected = value;
        invalidate(InvalidationType.STATE);
    }

    /**
     * Sets the internal mouse state.
     */
    public function setMouseState(state:String):void {
    }
}

}

要在单个单元格中显示多个图像吗? 您应该使用自定义GridItemRenderer:

<?xml version="1.0" encoding="utf-8"?>
<s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                xmlns:s="library://ns.adobe.com/flex/spark" 
                xmlns:mx="library://ns.adobe.com/flex/mx" clipAndEnableScrolling="true">

 <fx:Script>
    <![CDATA[
        override public function prepare(hasBeenRecycled:Boolean):void {
            img1.source = data.image1Source;
            img2.source = data.image2Source;
        }
    ]]>
 </fx:Script>

 <s:HGroup>
    <s:Image id="img1" />
    <s:Image id="img2" />
 </s:HGroup>    
</s:GridItemRenderer>

找到了答案。在setter中,如果我将value.data更改为value.myotherimagekeyname,则效果良好。