# Changing a button's color via a mouse click

**URL:** <https://forum.kirupa.com/t/changing-a-buttons-color-via-a-mouse-click/322920>\
**Category:** flash\
**Created:** [June 8, 2011, 5:26pm UTC](https://forum.kirupa.com/t/changing-a-buttons-color-via-a-mouse-click/322920 "2011-06-08T17:26:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carl\_Spackler](https://avatars.discourse-cdn.com/v4/letter/c/c5a1d2/32.png) [@Carl\_Spackler](https://forum.kirupa.com/u/Carl_Spackler)\
**Post date:** [June 8, 2011, 5:26pm UTC](https://forum.kirupa.com/t/changing-a-buttons-color-via-a-mouse-click/322920/1 "2011-06-08T17:26:29Z")

</div>

I’m trying to learn a simple way to code a button’s color to change when you click on the button itself. I got the button’s alpha to work by doing the following: Create a text field with the word “Preflight” and convert it to a button. Drag the button onto the stage and give it an instance name of “Preflight1”. On the first frame of the timeline, insert the following code:

import flash.events.MouseEvent;  
import flash.geom.ColorTransform;

Preflight1.addEventListener(MouseEvent.CLICK, Preflight1Click);  
function Preflight1Click(event:MouseEvent):void{  
Preflight1.alpha -=.1;  
}

Now when you test the movie, anytime you click the button “Preflight” the button’s alpha drops (dims) by 10%. Works perfect and easy. Now, how can I do this exact same thing with the button’s color? When you click the button, its color changes to some new color? I’ve tried colorTransform, but no luck.

Thanks much,

Carl
