actionscript-3 - 在 Flex 3 的 TileList 中移动效果

标签 actionscript-3 apache-flex actionscript flex3

我向您提供了我迄今为止所做的示例代码。我想要做的是,当我单击“向下”按钮时,Tilelist 会缓慢滚动并更改数据。虽然通过单击向下按钮更改了数据,但没有显示任何效果。我在网上搜索了很多,但找不到更好的方法。如果可能的话请给出最好的方法。

这是我到目前为止所做的示例代码

<?xml version="1.0"?>

<mx:Sequence id="dataChangeEffectSequence">
    <mx:Move duration="1500" easingFunction="{Elastic.easeOut}" perElementOffset="20"/>
</mx:Sequence>

<mx:Script>
    <![CDATA[
        import mx.effects.easing.Elastic;
        import mx.controls.Alert;
        import mx.events.ScrollEvent;

        private var arrImage:Array = [
            {source:"Images/1.png",tooltip:"1"},
            {source:"Images/2.png",tooltip:"2"},
            {source:"Images/3.png",tooltip:"3"},
            {source:"Images/4.png",tooltip:"4"},
            {source:"Images/5.png",tooltip:"5"},
            {source:"Images/6.png",tooltip:"6"},
            {source:"Images/7.png",tooltip:"7"},
            {source:"Images/8.png",tooltip:"8"},
            {source:"Images/9.png",tooltip:"9"},
            {source:"Images/10.png",tooltip:"10"}];

        public function onInit():void
        {
            tileList.dataProvider = arrImage;
        }

        public function btnUP_click():void
        {
            var scrollPosition:int = tileList.verticalScrollPosition - 1;

            if(scrollPosition >= 0)
            {
                tileList.verticalScrollPosition = scrollPosition;
            }
            else
            {
                tileList.verticalScrollPosition = 0;
            }
        }

        public function btnDown_click():void
        {
            var scrollPosition:int = tileList.verticalScrollPosition + 1;

            if(scrollPosition <= tileList.maxVerticalScrollPosition)
            {
                tileList.verticalScrollPosition = scrollPosition;
            }               
        }

    ]]>
</mx:Script>

<mx:Button width="100" label="UP" id="btnUP" click="{btnUP_click();}" />

<mx:TileList id="tileList" dataProvider="{arrImage}" columnCount="1" columnWidth="100"
    useRollOver="false" selectable="false" backgroundAlpha="0" borderStyle="none" 
    rowHeight="65" verticalScrollPolicy="off" horizontalScrollPolicy="off"
    itemsChangeEffect="{dataChangeEffectSequence}" >
    <mx:itemRenderer>
        <mx:Component>
            <mx:VBox width="100%" height="100%" horizontalAlign="center" verticalGap="0"
                verticalAlign="middle" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                <mx:Script>
                    <![CDATA[
                        import mx.controls.Alert;
                        override public function set data(value:Object):void
                        {
                            if(value !=null)
                            {
                                super.data = value;
                                if(img !=null)
                                {
                                    img.source = data.source;
                                    img.toolTip = data.tooltip;
                                }
                            }
                        }
                    ]]>
                </mx:Script>
                <mx:Image id="img" showEffect="{outerDocument.dataChangeEffectSequence}" />
            </mx:VBox>
        </mx:Component>
    </mx:itemRenderer>
</mx:TileList>

<mx:Button width="100" label="DOWN" id="btnDown" click="{btnDown_click();}" />

</mx:Application>

提前致谢..

最佳答案

将 TileList 放入容器(例如 Canvas 或 VBox)中,并强制其为所有项目的完整高度(如果您有variableRowHeight,则可能有点复杂)。然后处理 VBox 上的滚动,而不是 TileList。

另请注意,VBox 作为 itemRenderer 具有大量开销。您可能需要考虑将图像放在那里。它具有水平对齐和垂直对齐属性。

关于actionscript-3 - 在 Flex 3 的 TileList 中移动效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8503424/

相关文章:

actionscript-3 - 如何在 Haxe 中正确重写 getter 和 setter

actionscript-3 - 可以在没有 Adob​​e Flash Professional 的情况下使用 ActionScript 3 吗?

javascript - 大型网络应用的客户端技术

apache-flex - 组件没有得到垃圾收集

flash - 如何追踪网页内的ActionScript?

apache-flex - 错误 #3219 AIR 中的 NativeProcess

android - 如何从 flash 迁移到 adobe air iOs 和 android?

actionscript-3 - AS3公共(public)变量不会存储值

apache-flex - 在 Flex Datagrid 中添加分页的插件?

android - Android 中的 webStageView 本地 HTML 路径