views:

255

answers:

1

Hi,

I want to know if there is any existing implementation of 'endless scroll' in Flex ? I searched online but I could only find implementation in Javascript.

What could be the pros/cons of having an 'endless scroll' component in Flex, which would be more efficient JS or Flex.

Thanks

A: 

Possible solution for a List component:

Code:

        import mx.events.ScrollEvent;
        import mx.collections.ArrayCollection;

        [Bindable]
        private var dp : ArrayCollection = new ArrayCollection();

        private function init():void
        {
            var obj : Object;

            for (var k : int = 0; k < 20; k++ )
            {
                obj = new Object();
                obj.label = 'Label ' + k;

                dp.addItem(obj);
            }
        }

        private function onScroll(event:ScrollEvent):void
        {
            if (event.position > dp.length - list.rowCount - 3)
            {
                var obj : Object = new Object();
                obj.label = 'Label ' + dp.length;

                dp.addItem(obj);
            }
        }
    ]]>

MXML:

<mx:List id="list" dataProvider="{dp}" width="200" height="200" scroll="onScroll(event)"/>
mico