Copy link to clipboard
Copied
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
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", so
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now