actionscript 3 - Add color to label on list in flex -


i confused on how this.. have user list when joins adds them list (their username) have way find out if admin or not need know how can change color of each user in list... example....

if list supported html work fine

onlineusers.additem({label:"<font color='$ffffff'>users[i].username+"_guest</font>",id:users[i].userid,guest:"true"}); userlist.dataprovider = onlineusers 

but list not support html, know work around this?

generically, answer use itemrenderer.

all list class display other components (renderers) , send components data dataprovider display. really, mean default itemrenderer doesn't support html. technically make itemrenderer support html give color change need; i'd take different.

add property user object specifeis whether admin user or not. if user admin user; then; change color. conceptually this:

<s:itemrenderer xmlns:fx="http://ns.adobe.com/mxml/2009"      xmlns:mx="library://ns.adobe.com/flex/mx"      xmlns:s="library://ns.adobe.com/flex/spark"     autodrawbackground="false" datachange="ondatachange()">      <fx:script>         <![cdata[             public function ondatachange():void{                labeldisplay.text = data.username + "_guest";                if(data.isadmin){                  labeldisplay.setstyle('color',0xff0000);                } else {                  labeldisplay.setstyle('color',0x00ff00);                }             }         ]]>     </fx:script>      <s:label id="labeldisplay"          />  </s:itemrenderer> 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -