change button color


i have group of buttons , when each 1 clicked color should change. when button clicked color of previous button should change normal..plz help..thanks in advance

hi mssrivatsa,

 

you can below:

 

<?xml version="1.0" encoding="utf-8"?>
<mx:application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:script>
  <![cdata[
   private var previousbuttonclicked:button;
  
   private function buttonclickhandler(event:mouseevent):void
   {
    if(previousbuttonclicked)
    {
     previousbuttonclicked.setstyle("color","green");
    }
    previousbuttonclicked = event.currenttarget button;
    button(event.currenttarget).setstyle("color","red");
   }
  ]]>
</mx:script>

<mx:hbox>
  <mx:button id="btn1" label="button" color="green" click="buttonclickhandler(event);"/>
  <mx:button id="btn2" label="button" color="green" click="buttonclickhandler(event);"/>
  <mx:button id="btn3" label="button" color="green" click="buttonclickhandler(event);"/>
  <mx:button id="btn4" label="button" color="green" click="buttonclickhandler(event);"/>
  <mx:button id="btn5" label="button" color="green" click="buttonclickhandler(event);"/>
  <mx:button id="btn6" label="button" color="green" click="buttonclickhandler(event);"/>
  <mx:button id="btn7" label="button" color="green" click="buttonclickhandler(event);"/>
</mx:hbox>
</mx:application>

 


if post answers question or helps, please kindly mark such.


thanks,

bhasker chari



More discussions in Flex (Read Only)


adobe

Comments

Popular posts from this blog

Blank pages again for IE7 and IE6

How to update nested ListCollectionViews?

cf_sql_integer vs cf_sql_bigint vs cf_sql_int??