带有自定义 itemrender 的 as3 tilelist 添加到 selectedIndices

as3 tilelist with custom itemrender add to selectedIndices

我使用自定义渲染器创建了一个 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。

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

你能帮我做吗?

此致

看来你是想从反面解决问题,这是错误的 我想你可以考虑以下方式:

  • 将复选框的 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选中状态到renderer选中一个