# Event handler change button color for a state?

**URL:** <https://forum.kirupa.com/t/event-handler-change-button-color-for-a-state/2992>\
**Category:** flash\
**Created:** [February 18, 2002, 5:11am UTC](https://forum.kirupa.com/t/event-handler-change-button-color-for-a-state/2992 "2002-02-18T05:11:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 18, 2002, 5:11am UTC](https://forum.kirupa.com/t/event-handler-change-button-color-for-a-state/2992/1 "2002-02-18T05:11:33Z")

</div>

I am trying to figure out a way for an action script to change the background color of a particular button state.

I have a puzzle graphic. As the mouse moves over the pieces of the puzzle, the colors change. When the mouse clicks on the puzzle piece I want them to permanently change. However, I cannot figure out how to access the bgcolor property of a button state object, such as the up state.

Any help woul dbe appreciated.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 18, 2002, 8:36am UTC](https://forum.kirupa.com/t/event-handler-change-button-color-for-a-state/2992/2 "2002-02-18T08:36:18Z")

</div>

to change colour programatically, you’ll want to create a Color object that controls the object in question.

say the movie you wanted to change was called “bg”

bgcolour = new Color(bg);  
bgcolour.setRGB(0x349f0d);

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 18, 2002, 8:51am UTC](https://forum.kirupa.com/t/event-handler-change-button-color-for-a-state/2992/3 "2002-02-18T08:51:25Z")

</div>

And it HAS to be a movie clip. You can’t tell target buttons.

I’d say that you’re buttons should be invisible, and you should recreate the buttons that you have as movie clips.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 19, 2002, 6:50am UTC](https://forum.kirupa.com/t/event-handler-change-button-color-for-a-state/2992/4 "2002-02-19T06:50:49Z")

</div>

I am having a problem referencing the object for the movie clip. I drew a shape and made two symbols out of it:

b1 : a button symbol  
mc1: a movie clip symbol

I then made an instance of b1 and made it transparent. I then made an instance of mc1. However, I cannot name an instance so how do I go about referencing the instance of mc1 in order to create a color object? The only referennce I can see is \_root.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 19, 2002, 6:56am UTC](https://forum.kirupa.com/t/event-handler-change-button-color-for-a-state/2992/5 "2002-02-19T06:56:17Z")

</div>

Ah, I’m a moron. I failed to notice that in the instance panel for the movie clip it clearly has a name field. The transparent button with associated movie clip is perfect. Muchas gracias.
