将扩展滚动条添加到Flex

时间:2015-09-09 14:48:08

标签: list actionscript-3 flex flex4

我尝试添加自定义Scroller.as(从spark.components.Scroller扩展到)InfiniteScrollList.as(从spark.components.list扩展)

我写了以下MXML代码:

<list:InfiniteScrollList width="100%" height="100%" id="EventsList" useVirtualLayout="true">
    <list:scroller>
         <list:Scroller/> <!-- The Scroller.as Class -->
    </list:scroller>
</list:InfiniteScrollList>

List行为运行良好但扩展的Scroller组件根本不起作用。
将此滚动功能(在MXML或ActionScript中)添加到列表的正确方法是什么?

1 个答案:

答案 0 :(得分:1)

s:Scroller用于将其包装在内容或DataGroup周围。但是List类将所有功能包装在它的皮肤中,所以我相信为了为List创建一个自定义Scroller,你实际上需要在SkinClass中进行。

<list:InfiniteScrollList  width="100%" height="100%"  id="EventsList"
      useVirtualLayout="true" skinClass="MyListSkin" />

MyListSkin.mxml:

<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
  xmlns:fb="http://ns.adobe.com/flashbuilder/2009" minWidth="112"> 

<fx:Metadata>
    [HostComponent("spark.components.Scroller")]
</fx:Metadata> 

<s:states>
    <s:State name="normal" />
    <s:State name="disabled" />
</s:states>


    <!-- The Scroller.as Class -->
    <list:Scroller left="0" top="0" right="0" bottom="0" id="scroller" hasFocusableChildren="false">
        <!--- @copy spark.components.SkinnableDataContainer#dataGroup -->
        <s:DataGroup id="dataGroup" itemRenderer="spark.skins.spark.DefaultItemRenderer">
            <s:layout>
                <!--- The default layout is vertical and measures at least for 5 rows.  
                When switching to a different layout, HorizontalLayout for example,
                make sure to adjust the minWidth, minHeight sizes of the skin -->
                <s:VerticalLayout gap="0" horizontalAlign="contentJustify" requestedMinRowCount="5" />
            </s:layout>
        </s:DataGroup>
    </list:Scroller/>
</s:SparkSkin>