Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.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
Apache flex (flex)-数据更改效果播放-自定义项目渲染器_Apache Flex_Itemrenderer_Effect - Fatal编程技术网

Apache flex (flex)-数据更改效果播放-自定义项目渲染器

Apache flex (flex)-数据更改效果播放-自定义项目渲染器,apache-flex,itemrenderer,effect,Apache Flex,Itemrenderer,Effect,我有带有自定义itemrenderer的datagrid。我想为一个单元格播放animatecolor效果,其中的数据已更改。我不想对所有细胞都产生这种效果 下面是itemrenderer的代码: <?xml version="1.0" encoding="utf-8"?> <s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns

我有带有自定义itemrenderer的datagrid。我想为一个单元格播放animatecolor效果,其中的数据已更改。我不想对所有细胞都产生这种效果

下面是itemrenderer的代码:

<?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:Declarations>
    <s:Sequence id      =   "updateEffect">
        <s:AnimateColor colorFrom   ="0xffffff"
                        colorTo     ="0xb9d30d"
                        target  =   "{lblData}"
                        duration    ="5000"/>
        <s:AnimateColor colorFrom   ="0xb9d30d"
                        colorTo     ="0xffffff"
                        target  =   "{lblData}"
                        duration    ="5000"/>
    </s:Sequence>
</fx:Declarations>
<fx:Script>
    <![CDATA[
        import mx.controls.Alert;
        import mx.events.FlexEvent;

        override public function prepare(hasBeenRecycled:Boolean):void {
            if(data)
            {
                lblData.text = data[column.dataField];
                if(data.selected == true)
                {
                    lblData.setStyle("color","#61afda");
                    lblData.setStyle("textAlign","center");
                    lblData.setStyle("fontWeight","bold");
                    lblData.setStyle("fontSize","19");
                    lblData.setStyle("paddingLeft","10");
                    lblData.setStyle("paddingRight","10");
                    lblData.setStyle("paddingBottom","0");
                    lblData.setStyle("paddingTop","2");         
                    containter.setStyle("backgroundAlpha","1.0");
                    containter.setStyle("backgroundColor","0x2f3437");
                }
                else
                {   
                    lblData.setStyle("color","#d4d4d4");
                    lblData.setStyle("textAlign","center");
                    lblData.setStyle("fontWeight","bold");
                    lblData.setStyle("fontSize","12");
                    lblData.setStyle("paddingLeft","10");
                    lblData.setStyle("paddingRight","10");
                    lblData.setStyle("paddingBottom","5");
                    lblData.setStyle("paddingTop","4");
                    containter.setStyle("backgroundAlpha","0.0");
                    updateEffect.play();
                }
            }
        }
    ]]>
</fx:Script>
<s:SkinnableContainer
    id          ="containter"
    width       ="100%"
    height      ="100%">

    <s:HGroup
        width       ="100%"
        height      ="100%">

        <s:Label
            id                  ="lblData"

            width               ="100%"
            height              ="100%"
            maxDisplayedLines   ="1"
            styleName           ="FPlayGcItemRenderStyle"/>


    </s:HGroup>

</s:SkinnableContainer>


有什么建议吗?

我不知道这是否是最好的方法,但当我需要在项目呈现器中动态更新属性时,我通常会在数据中添加一个侦听器

//This is inside an item renderer
private var _myClass:FunkyClass;
override protected function set data( value:Object ):void
{
    super.data = value;
    if( value != null )
    {
        if( _myClass != null )
        {
            _myClass.removeEventListener( 
                  'MyFunkyClass.DataChange' , updateSomething);
        }
        _myClass = value as FunkyClass;
        _myClass.addEventListener( 
                  'MyFunkyClass.DataChange' , updateSomething);
    }
}

private function updateSomething( event:Event ):void
{
    //change colors, visibility and so forth
}
当然,您的数据类必须扩展EventDispatcher。我还想看看社区中的其他人是如何解决这个问题的