| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Nov 2004
Posts: 53
|
I'd like to change the fontcolor of a selected item in a list (ie. you click on the list item and it changes colors or font weight).
Here is my partical mxml which does not work: <mx:Script> <![CDATA[ private function answerSelected(even:flash.events.Event):void { event.target.selectedItem.setStyle("fontColor", "red"); } <mx:VBox> <mx:List id="answers" dataProvider="{myCollection"} change="answerSelected" /> </mx:VBox> I've been struggling with these for 2 days...you're help is appreciated. Steve |
|
|
|
|
|
#2 |
|
lala
Join Date: Feb 2002
Location: on the road
Posts: 2,859
|
event.target.selectedItem.setStyle("fontColor", 0xFF0000);
|
|
|
|
|
|
|
|
|
#3 |
|
Addict
Join Date: Nov 2001
Location: London
Posts: 2,128
|
I think you'd get an error on that as the event.target will return a DisplayObject, and these don't have a 'selectedItem' prop. You just need to cast it first.
var myList:List = List(event.target); myList.selectedItem.setStyle("fontColor", 0xFF0000); |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Changing the selected item in a combobox | mcmcom | Components | 3 | 07-28-2006 12:42 PM |
| knowing which item in a list that is selected? | Clox | ActionScript 2.0 | 12 | 09-01-2005 02:21 PM |
| changing list component item text color | nitinmukesh123 | Components | 0 | 05-16-2005 02:24 PM |
| setting a list box item as selected without selecting it | brolife | Components | 4 | 03-21-2005 04:59 AM |