views:

634

answers:

1

I have 2 TileList component in my Flex application.

1 tilelist is filled with data much like following xml sample:

<person name="Test">
<likes>Flex</likes>
<likes>PHP</likes>
</person>
<person name="test2">
<likes>HTML</likes>
<likes>CSS</likes>
</person>

the data shown in that tilelist is the name.

my second tilelist:

<items>
<preference>Flex</preference>
<preference>Flash</preference>
<preference>HTML</preference>
<preference>CSS</preference>
<preference>PHP</preference>
<preference>CMS</preference>
<preference>ASP</preference>
<preference>C</preference>
</items>

data shown is the preference.

The user can click the first tilelist and then the items that person "likes" should be selected in the second tilelist (in other words they lit up).

click event on my first tilelist

private function highlightPreferences(e:ListEvent):void{
trace(e.currentTarget);
//and now I'm stuck
}

Is there any way to achieve this?

+1  A: 

Just write a function that returns the selectedIndices for a particular person. Then, bind the second TileList's selectedIndices like this: selectedIndices="{findLikes(firstList.selectedItem)}" The binding will fire if firstList.selectedItem changes.

Oh, and please don't use a repeater. Lists can do everything repeater can better.

Sean Clark Hess
thx for your answer although I don't like the tilelist solution. Mainly because tilelist are a bit more limited (and more difficult to code). example: you have a tilelist with 4 items in it, each needs a diffirent backgroundcolor when clicked AND multiple selection is an option.I guess I'm not used to working with tilelist to write the code fluently.
Jozzeh
Yeah, it's definitely harder at first, but mastering lists in flex is one of the best things I ever did. The problem is you have to start thinking of them as data-driven components. So, you have a property in your dataprovider, like `selected`, and have your item renderers bind to it to decide the background color. Then, you can just change the selected property on your data when it is selected, or use binding.
Sean Clark Hess