Your makefivered() function is referencing an item in the dataProvider, not a button in the repeater.

 

Put an id on the button in the repeater: “myButton” , then in the function, reference it using the array index:

myButton[4].setStyle("color","0xCC0066");

 

I believe you must use setStyle to ser colors.  I couldn’t get anything but black when I tried to use fillColors, but you can probably figure that out,

 

Tracy

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, March 21, 2005 10:35 AM
To: [email protected]
Subject: [flexcoders] How do you change the color of an array object

 

I have been trying to make an array of buttons and have one button change the color of one of them. But for some reason this code does not work and I was wondering if someone could explain this to me.

 

 

 

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Script>
<![CDATA[

 

public function makefivered()
{
tenlittlebuttons[4].fillColors=["grey"];
}

 

]]>
</mx:Script>
<mx:Array id="tenlittlebuttons">
<mx:Object label="1" />

 

<mx:Object label="2" />
<mx:Object label="3" />
<mx:Object label="4" />
<mx:Object label="4" />
<mx:Object label="5" />
<mx:Object label="6" />
<mx:Object label="7" />
<mx:Object label="8" />
<mx:Object label="9"/>
<mx:Object label="10" />

 

</mx:Array>
<mx:HBox><mx:Button label="changefive"  click="makefivered()"/>

 


<mx:Repeater id="theten" dataProvider="{tenlittlebuttons}">
<mx:Button label="{theten.currentItem.label}" />
</mx:Repeater>

 

</mx:HBox>

 

</mx:Application>




Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links

Reply via email to