as3 tilelist with custom itemrender add to selectedIndices

时间:2017-11-30 17:33:24

标签: actionscript-3 flex

我使用自定义渲染器创建TileList。

    <s:BorderContainer
                   id="bcImage"
                   width="120"
                   height="99%"
                   borderVisible="true"
                   borderStyle="solid"
                   borderColor="#B3B3B3"
                   borderWeight="1"
                   cornerRadius="2"
                   backgroundAlpha=".8"
                   backgroundColor="#F8F8FF"
                   dropShadowVisible="true"
                   >




    <mx:Canvas id="cvsImage" width="100%" click="cvsImage_clickHandler(event)">

        <s:HGroup width="100%" paddingBottom="0" paddingTop="5" >
            <s:CheckBox id="cbImgSelect"/>
            <s:Label x="23" y="3" width="82" fontSize="11" fontWeight="normal" text="{data.imDate}"
                     textAlign="right" color="#000000"/>    
        </s:HGroup>  


        <mx:Image id="iconCanvas" x="10" y="20" width="99" height="99" horizontalAlign="center"
                  maintainAspectRatio="true" scaleContent="true"
                  verticalAlign="middle" mouseDown="iconCanvas_mouseDownHandler(event)"
                  >

        </mx:Image>
    </mx:Canvas>

    <s:BorderContainer width="100%" y="124" height="25" bottom="1" left="3" right="3" 
                       backgroundColor="#FFFFFF" id="bcTitre" borderAlpha="0" >
        <s:VGroup width="100%" y="124" height="25" bottom="0" left="0" right="0"
                  paddingBottom="0" paddingTop="0" gap="0" click="iconCanvasLabel_mouseUp(event)">
            <s:Label text="{data.imType}" height="50%" fontSize="10" paddingBottom="1" id="lType"
                     fontWeight="normal" width="99%" textAlign="center" toolTip="{data.imType}"/>
            <s:Label text="{data.imStade}" fontSize="10" textAlign="center" paddingTop="1"
                     fontWeight="normal" width="99%" id="lStade" toolTip="{data.imStade}"/> 

        </s:VGroup>
    </s:BorderContainer>


</s:BorderContainer>

我的TileList具有allowMultipleSelection enable。

当我通过点击或选择(继续或不选择)选择项目时,我会检查CheckBox,如果CheckBox.selected = true,我想在所选项目周围显示颜色选择。

你能帮帮我吗?

祝你好运

1 个答案:

答案 0 :(得分:0)

您似乎正试图从相反的方面解决问题,这是错误的 我想你可以考虑以下方式:

  • 为checkBox设置mouseEnabled为false,以便所有列表项触发器单击
  • 通过拦截changing事件并执行类似

    之类的操作来更改默认选择行为
    protected function lst_changingHandler(evt:IndexChangeEvent):void {
            evt.preventDefault();
            var ids:Vector.<int> = (evt.currentTarget as List).selectedIndices;
            (evt.currentTarget as List).selectedIndices = ids.concat(new <int>[evt.newIndex]);
    
  • 将checkBox选中状态绑定到选定的渲染器