Flex Tutorial #1: Colour a Button using a Colour Picker

Ok guys, this is the first of my tutorials in Flex, and I will regularly be writing up tutorials to help other fellow Flex developers learn a few basic tricks. Please feel free to comment or offer suggestions (or G-D forbid even correct me) on each of my Tutorials:
And for the first tutorial, I will show you how to change the colour of a button or any object for that matter, using a colour picker. In the MXML, enter the following:

...
<mx:ColorPicker change="changeButtonColour(event)" />
<mx:Button id="test_Button" label="Change My Colour"
click="" />

<mx:script>
<![CDATA[
import mx.events.ColorPickerEvent;
private function changeButtonColour(e:ColorPickerEvent):void
{ test_Button.setStyle("backgroundColor", e.color); }
</mx:script>

[ad#WidgetbucksComputers]

Advertisements
This entry was posted in General and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s