Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Flex > Flex 2 & 3

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-13-2006, 04:14 PM   #1
djsodom
Registered User
 
Join Date: Nov 2004
Posts: 53
Default changing style of selected item in a list

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
djsodom is offline   Reply With Quote
Old 07-19-2006, 10:30 AM   #2
hangalot
lala
 
hangalot's Avatar
 
Join Date: Feb 2002
Location: on the road
Posts: 2,859
Default

event.target.selectedItem.setStyle("fontColor", 0xFF0000);
__________________
oi poloi
http://www.memorphic.com/news/
hangalot is offline   Reply With Quote
Old 07-19-2006, 12:08 PM   #3
Tink
Addict
 
Tink's Avatar
 
Join Date: Nov 2001
Location: London
Posts: 2,128
Default

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);
Tink is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT. The time now is 08:03 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.