Skip to main content
December 29, 2012
Answered

Unhighlighting items in a TileList

  • December 29, 2012
  • 1 reply
  • 831 views

Good morning,

I'm trying to figure out how to unhighlight/deselect an item in a TileList.  When the list is initialized, no items are highlighted, but once you click an item, it seems there is no way to unhighlight/remove that blue background once an item has been clicked. 

I've tried resetting the selected index manually to -1, and using the clearSelection() method, and while that does seem to change the index to -1, the actual image itself is still highlighted and appears to be selected.

I've searched tutorials and sites for the past day, and tried playing around with code, to no avail.

Here is my basic code (based off the Adobe help example), I've erased all the attempts and tactics I've tried to make it work, so this is just the basic example:

package

{

    import fl.controls.TileList;

    import fl.controls.ScrollBarDirection;

    import flash.display.MovieClip;

    import fl.events.ListEvent;

    import flash.events.Event;

    public class TileListExample extends MovieClip

    {

        var myTileList:TileList = new TileList();

        public function TileListExample()

        {

            myTileList.addItem({label:"Image 1", source:"http://www.helpexamples.com/flash/images/image1.jpg"});

            myTileList.addItem({label:"Image 2", source:"http://www.helpexamples.com/flash/images/image2.jpg"});

            myTileList.addItem({label:"Image 3", source:"http://www.helpexamples.com/flash/images/image3.jpg"});

            myTileList.direction = ScrollBarDirection.VERTICAL;

            myTileList.columnWidth = 200;

            myTileList.rowHeight = 150;

            myTileList.columnCount = 1;

            myTileList.rowCount = 2;

            myTileList.move(10, 10);

            addChild(myTileList);

            myTileList.addEventListener(ListEvent.ITEM_CLICK, itemClicked);

        }

        private function itemClicked(e:Event)

        {

            myTileList.clearSelection();

        }

    }

}

Thanks

This topic has been closed for replies.
Correct answer kglad

use:

package

{

    import fl.controls.TileList;

    import fl.controls.ScrollBarDirection;

    import flash.display.MovieClip;

    import fl.events.ListEvent;

    import flash.events.Event;

    public class TileListExample extends MovieClip

    {

        var myTileList:TileList = new TileList();

        public function TileListExample()

        {

            myTileList.addItem({label:"Image 1", source:"http://www.helpexamples.com/flash/images/image1.jpg"});

            myTileList.addItem({label:"Image 2", source:"http://www.helpexamples.com/flash/images/image2.jpg"});

            myTileList.addItem({label:"Image 3", source:"http://www.helpexamples.com/flash/images/image3.jpg"});

            myTileList.direction = ScrollBarDirection.VERTICAL;

            myTileList.columnWidth = 200;

            myTileList.rowHeight = 150;

            myTileList.columnCount = 1;

            myTileList.rowCount = 2;

            myTileList.move(10, 10);

            addChild(myTileList);

myTileList.selectable=false;

            myTileList.addEventListener(ListEvent.ITEM_CLICK, itemClicked);

        }

        private function itemClicked(e:Event)

        {

            myTileList.clearSelection();

        }

    }

}

p.s. please mark helpful/correct responses.

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
December 29, 2012

use:

package

{

    import fl.controls.TileList;

    import fl.controls.ScrollBarDirection;

    import flash.display.MovieClip;

    import fl.events.ListEvent;

    import flash.events.Event;

    public class TileListExample extends MovieClip

    {

        var myTileList:TileList = new TileList();

        public function TileListExample()

        {

            myTileList.addItem({label:"Image 1", source:"http://www.helpexamples.com/flash/images/image1.jpg"});

            myTileList.addItem({label:"Image 2", source:"http://www.helpexamples.com/flash/images/image2.jpg"});

            myTileList.addItem({label:"Image 3", source:"http://www.helpexamples.com/flash/images/image3.jpg"});

            myTileList.direction = ScrollBarDirection.VERTICAL;

            myTileList.columnWidth = 200;

            myTileList.rowHeight = 150;

            myTileList.columnCount = 1;

            myTileList.rowCount = 2;

            myTileList.move(10, 10);

            addChild(myTileList);

myTileList.selectable=false;

            myTileList.addEventListener(ListEvent.ITEM_CLICK, itemClicked);

        }

        private function itemClicked(e:Event)

        {

            myTileList.clearSelection();

        }

    }

}

p.s. please mark helpful/correct responses.

December 29, 2012

Thanks!  You gave me the key, and from there I figured out how to toggle the selection on/off.

I'll clean up my code, add some comments and then post the solution I went with.

Thanks again!

kglad
Community Expert
Community Expert
December 29, 2012

you're welcome.