1 Reply Latest reply on Jun 9, 2007 8:42 PM by chris.huston.t10

    Programmatically select all items in a list

    LordPathogen
      Hi, I've been looking through the online docs trying to find a way to programmatically select all items in a list. I have a checkbox that when checked should select all items in a list. I found a method to clear all selections but not one to select all. Did I just miss it? Thanks!
        • 1. Re: Programmatically select all items in a list
          chris.huston.t10 Level 3
          I don't know of any built-in functions to select all list items, but here is an example function to select all items in a list:

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute">
          <mx:Script>
          <![CDATA[
          [Bindable] private var people_xml:XML =
          <people>
          <person>Jen</person>
          <person>Brian</person>
          <person>Scot</person>
          </people>;

          private function select_all():void {
          var indices:Array = new Array();
          for (var i:uint = 0; i<people_xml.children().length(); i++) {
          indices.push(i);
          }
          peopleList.selectedIndices = indices;
          }
          ]]>
          </mx:Script>
          <mx:Button x="125" y="10" label="Select All" click="select_all()"/>
          <mx:List x="10" y="10" allowMultipleSelection="true" dataProvider="{people_xml.person}" id="peopleList" labelField="person" width="107"></mx:List>
          </mx:Application>

          Vygo